class Liebre::Actor::Context::Handler
Constants
- DEFAULT_POOL_SIZE
Attributes
opts[R]
Public Class Methods
new(opts)
click to toggle source
# File lib/liebre/actor/context/handler.rb, line 10 def initialize opts @opts = opts end
Public Instance Methods
call(*args, &block)
click to toggle source
# File lib/liebre/actor/context/handler.rb, line 14 def call *args, &block pool.post { handle(args, block) } end
Private Instance Methods
handle(args, block)
click to toggle source
# File lib/liebre/actor/context/handler.rb, line 20 def handle args, block handler = handler_class.new(*args) handler.call rescue => error block.call(error) end
handler_class()
click to toggle source
# File lib/liebre/actor/context/handler.rb, line 35 def handler_class @handler_class ||= opts.fetch(:handler) end
pool()
click to toggle source
# File lib/liebre/actor/context/handler.rb, line 27 def pool @pool ||= begin size = opts.fetch(:pool_size, DEFAULT_POOL_SIZE) Concurrent::FixedThreadPool.new(size) end end