module Fibre

Fiber pool

Example,

using EventObject
pool = Fibre::FiberPool.new(10)
pool.checkout do
  puts "runned in fiber"
end

Constants

DEFAULT_POOL_QUEUE_SIZE
DEFAULT_POOL_SIZE
FIBER_POOL_THREADED
VERSION

Attributes

root[RW]

Establish the root fiber

Public Instance Methods

init_pool(*a) click to toggle source
# File lib/fibre.rb, line 26
def init_pool(*a)
  Thread.current[FIBER_POOL_THREADED] = make_pool(*a)
end
make_pool(pool_size: DEFAULT_POOL_SIZE, pool_queue_size: DEFAULT_POOL_QUEUE_SIZE) click to toggle source
# File lib/fibre.rb, line 40
def make_pool(pool_size: DEFAULT_POOL_SIZE, pool_queue_size: DEFAULT_POOL_QUEUE_SIZE)
  FiberPool.new(pool_size: pool_size, pool_queue_size: pool_queue_size)
end
pool() click to toggle source

Auto-initialize at first call and each thread has own fiber pool

# File lib/fibre.rb, line 31
def pool
  Thread.current[FIBER_POOL_THREADED] ||= make_pool
end
reset() click to toggle source
# File lib/fibre.rb, line 35
def reset
  Thread.current[FIBER_POOL_THREADED] = nil
  pool
end