free_mutant/lib/mutant/actor/sender.rb
2015-07-02 03:35:54 +00:00

26 lines
507 B
Ruby

module Mutant
module Actor
# Sender for messages to acting thread
class Sender
include Adamantium::Flat, Concord.new(:condition_variable, :mutex, :messages)
# Send a message to actor
#
# @param [Object] message
#
# @return [self]
#
# @api private
def call(message)
mutex.synchronize do
messages << message
condition_variable.signal
end
self
end
end # Sender
end # Actor
end # Mutant