The GreenPool class is a pool of green threads.
Returns the number of greenthreads available for use.
If zero or less, the next call to spawn() or spawn_n() will block the calling greenthread until a slot becomes available.
Change the max number of greenthreads doing work at any given time.
If resize is called when there are more than new_size greenthreads already working on tasks, they will be allowed to complete but no new tasks will be allowed to get launched until enough greenthreads finish their tasks to drop the overall quantity below new_size. Until then, the return value of free() will be negative.
Run the function with its arguments in its own green thread. Returns the GreenThread object that is running the function, which can be used to retrieve the results.
If the pool is currently at capacity, spawn will block until one of the running greenthreads completes its task and frees up a slot.
This function is reentrant; function can call spawn on the same pool without risk of deadlocking the whole thing.
GreenPile is an abstraction representing a bunch of I/O-related tasks.
Construct a GreenPile with an existing GreenPool object. The GreenPile will then use that pool’s concurrency as it processes its jobs. There can be many GreenPiles associated with a single GreenPool.
A GreenPile can also be constructed standalone, not associated with any GreenPool. To do this, construct it with an integer size parameter instead of a GreenPool.
It is not advisable to iterate over a GreenPile in a different greenthread than the one which is calling spawn. The iterator will exit early in that situation.