Sha256: 99705130e22ba249da3f448ccafe793123f61d1e501a40afcc7a8b447e0f6f66
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
module Mutant module Actor # Receiver side of an actor class Receiver include Concord.new(:mutex, :mailbox) # Receives a message, blocking # # @return [Object] # # @api private # def call 2.times do message = try_blocking_receive return message unless message.equal?(Undefined) end fail ProtocolError end private # Try a blocking receive # # @return [Undefined] # if there is no message yet # # @return [Object] # if there is a message # # @api private # def try_blocking_receive mutex.lock if mailbox.empty? mutex.unlock Thread.stop Undefined else mailbox.shift.tap do mutex.unlock end end end end # Receiver end # Actor end # Mutant
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mutant-0.7.1 | lib/mutant/actor/receiver.rb |