Class: ZooKeeper::EventMachine::AsyncOp

Inherits:
AsyncOp
  • Object
show all
Defined in:
lib/zkruby/eventmachine.rb

Overview

class Binding

Instance Attribute Summary

Attributes inherited from AsyncOp

#backtrace

Instance Method Summary collapse

Methods inherited from AsyncOp

#errback, #errback=, #value

Constructor Details

#initialize(binding, &callback) ⇒ AsyncOp

Returns a new instance of AsyncOp.



145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/zkruby/eventmachine.rb', line 145

def initialize(binding,&callback)
    @em_binding = binding

    # Wrap the callback in its own Strand
    @op_strand = Strand.new do
        #immediately pause
        error, response = Strand.yield
        Strand.current[ZooKeeper::CURRENT] =  [ @em_binding.client ] 
        raise error if error
        callback.call(response)
    end
end

Instance Method Details

#resume(error, response) ⇒ Object



158
159
160
161
# File 'lib/zkruby/eventmachine.rb', line 158

def resume(error,response)
    #TODO - raise issue in strand for resume to take arguments
    op_strand.fiber.resume(error,response)
end