Class: EventMachine::SpawnedProcess
- Inherits:
-
Object
- Object
- EventMachine::SpawnedProcess
- Defined in:
- lib/em/spawnable.rb
Instance Method Summary collapse
-
#notify(*x) ⇒ Object
(also: #resume, #run)
attr_accessor :receiver.
-
#set_receiver(blk) ⇒ Object
I know I’m missing something stupid, but the inside of class << s can’t see locally-bound values.
Instance Method Details
#notify(*x) ⇒ Object Also known as: resume, run
attr_accessor :receiver
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/em/spawnable.rb', line 34 def notify *x me = self EM.next_tick { # A notification executes in the context of this # SpawnedProcess object. That makes self and notify # work as one would expect. # y = me.call(*x) if y and y.respond_to?(:pull_out_yield_block) a,b = y.pull_out_yield_block set_receiver a self.notify if b end } end |
#set_receiver(blk) ⇒ Object
I know I’m missing something stupid, but the inside of class << s can’t see locally-bound values. It can see globals, though.
54 55 56 57 58 59 |
# File 'lib/em/spawnable.rb', line 54 def set_receiver blk $em______tmpglobal = blk class << self define_method :call, $em______tmpglobal.dup end end |