This is a created article in which the information may have evolved or changed.
Today, on the subway, it occurred to me that it was possible to use the channel in go to easily implement the asynchronous function in ASIO. In fact, ASIO mainly with the use of function variables to hold the code, and it is because C and C + + do not support the reflection, there is no problem in go, the direct use of reflection can be done. Asynchronous execution in Go can be simple, because Channle is naturally a queue, and we start by specifying the channel buffer (which is better than ASIO, because the size of the buffer can solve the problem of traffic control that cannot be solved by the asynchronous program), The code to be executed is then dropped to the channel, a dedicated goroutine to continuously read the execution instructions in the channel and then process. In fact, this multithreading idea is consistent with the idea of solving concurrency in the Go language design, which is to solve the problem by moving data rather than locking it. Just make sure that a single data is processed in one line thread.
But unfortunately, the go language of the current net package does not support non-blocking, and goroutine itself is a closure, and Golang claims that goroutine consumption is very small, the cost of switching is very small, which seems to achieve a ASIO does not make any sense. So this is just a sudden thought on the way to work, there is no need to achieve.