Reputation: 51263
I'm currently allocating new coroutine instances quite often (see the code in my answer here).
The overhead of this is not trivial.
I would guess that there is some way to make this cheaper by reusing the previously allocated coroutine?
Not sure how to achieve this though?
I could use a boost::pool for the coroutine Allocator
. However, that will not work for the StackAllocator
, which is the expensive one...
Upvotes: 2
Views: 327
Reputation: 400
A coroutine contains a stack and a control block (preserved registers, put at the edge of the stack). You could not reuse the coroutine itself but you could write your own stack-allocator which pre-allocates and caches stacks. A newly created coroutine could re-use an already allocated stack from the cache.
Upvotes: 3