Class: Celluloid::Proxy::Block
- Inherits:
-
Object
- Object
- Celluloid::Proxy::Block
- Defined in:
- lib/celluloid/proxy/block.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#call ⇒ Object
readonly
Returns the value of attribute call.
-
#execution ⇒ Object
writeonly
Sets the attribute execution.
Instance Method Summary collapse
-
#initialize(mailbox, call, block) ⇒ Block
constructor
A new instance of Block.
- #to_proc ⇒ Object
Constructor Details
#initialize(mailbox, call, block) ⇒ Block
Returns a new instance of Block.
5 6 7 8 9 10 |
# File 'lib/celluloid/proxy/block.rb', line 5 def initialize(mailbox, call, block) @mailbox = mailbox @call = call @block = block @execution = :sender end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/celluloid/proxy/block.rb', line 3 def block @block end |
#call ⇒ Object (readonly)
Returns the value of attribute call.
3 4 5 |
# File 'lib/celluloid/proxy/block.rb', line 3 def call @call end |
#execution=(value) ⇒ Object (writeonly)
Sets the attribute execution
2 3 4 |
# File 'lib/celluloid/proxy/block.rb', line 2 def execution=(value) @execution = value end |
Instance Method Details
#to_proc ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/celluloid/proxy/block.rb', line 12 def to_proc if @execution == :sender lambda do |*values| if task = Thread.current[:celluloid_task] @mailbox << ::Celluloid::Call::Block.new(self, ::Celluloid::Actor.current.mailbox, values) # TODO: if respond fails, the Task will never be resumed task.suspend(:invokeblock) else # FIXME: better exception raise "No task to suspend" end end else @block end end |