lib/plumbing/actor/async.rb in standard-procedure-plumbing-0.4.5 vs lib/plumbing/actor/async.rb in standard-procedure-plumbing-0.4.6

- old
+ new

@@ -7,32 +7,37 @@ class Async attr_reader :target def initialize target @target = target - @queue = [] - @semaphore = ::Async::Semaphore.new(1) + @semaphore = ::Async::Semaphore.new(Plumbing.config.max_concurrency) end # Send the message to the target and wrap the result - def send_message(message_name, *, **, &) + def send_message(message_name, *args, **params, &block) + Plumbing.config.logger.debug { "-> #{@target.class}##{message_name}(#{args.inspect}, #{params.inspect})" } task = @semaphore.async do - @target.send(message_name, *, **, &) + Plumbing.config.logger.debug { "---> #{@target.class}##{message_name}(#{args.inspect}, #{params.inspect})" } + @target.send(message_name, *args, **params, &block) end + sleep 0.01 Result.new(task) end def safely(&) + Plumbing.config.logger.debug { "-> #{@target.class}#perform_safely" } send_message(:perform_safely, &) + sleep 0.01 nil end def in_context? = true def stop = nil Result = Data.define(:task) do def value + sleep 0.01 Timeout.timeout(Plumbing::Actor.timeout) do task.wait end end end