seastar::thread 是堆栈协程吗?

Is seastar::thread a stackful coroutine?

Seastar allows writing such code, by using a seastar::thread object which comes with its own stack.

The seastar::thread allocates a 128KB stack, and runs the given function until then it blocks on the call to a future's get() method. Outside a seastar::thread context, get() may only be called on a future which is already available. But inside a thread, calling get() on a future which is not yet available stops running the thread function, and schedules a continuation for this future, which continues to run the thread's function (on the same saved stack) when the future becomes available.

以上句子引用自seastar tutorial,是不是说明seastar::thread是stackful协程的一种?

是的,seastar::thread和“stackful coroutines”确实是非常相似的概念。

请注意,Seastar 还支持 stackless 协程,使用新的 C++20 协程功能。现在,这几乎总是优于堆栈协程 (seastar::thread):无堆栈协程更轻巧,并且在高并发操作中也很有用(每个服务员一个堆栈是很大的浪费),在 C++ 语言中有更好的支持。 Stackless 协程也能更好地与 future-based 代码协作——当你编写一个函数时假设它是 seastar::thread 中的 运行,即在未准备好的期货上使用 get(),你只能调用这个函数来自seastar::thread。相反,如果您使用新的 C++ 语法编写无堆栈协程 - 您可以从任何 future-based 或 coroutine-based 代码调用它。