I recently discussed how async-wait works, and I want to know if I received it correctly.
Does async-wait work by switching the ESP stack pointer to point to another stack stack? It will be like WINAPI fibers or the old Win3.1 collaborative multitasking.
For example, consider this code:
int Foo() {
int y = ReadSomethingFromConsole();
int x = await DoSomethingAsync();
return x+y;
}
The call stack will look like this:
EventLoop(...);
.......
Foo();
At the moment when we reach the operator await, it is planned to start a new task in the thread pool, and awaitimmediately switches the ESP pointer to the new stack frame in which we are on the EventLoop()function. The current stack frame memory segment is not discarded, but the ESP no longer points to it.
, . ESP Foo().
, ?
: , await? "", ?