A pool of initialized fibers It does not grow in size or create transient fibers It will queue code blocks when needed (if all its fibers are busy)
This class is particulary useful when you use the fibers to connect to evented back ends. It also does not generate transient objects and thus saves memory.
Example:
fiber_pool = NeverBlock::Pool::FiberPool.new(150)
loop do
fiber_pool.spawn do
#fiber body goes here
end
end
Methods
Attributes
| [RW] | fibers |
Public Class methods
new(count = 50)
[ source ]
Prepare a list of fibers that are able to run different blocks of code every time once a fiber is done with its block it attempts to fetch another one from the queue.
Public Instance methods
spawn(&block)
[ source ]
If there is an available fiber use it, otherwise, leave it to linger in a queue