Module: Swift::Adapter::Eventmachine
- Included in:
- Eventmachine::Mysql, Eventmachine::Postgres
- Defined in:
- lib/swift/adapter/eventmachine.rb
Defined Under Namespace
Classes: Handler, Mysql, Postgres
Instance Method Summary collapse
-
#execute(command, *bind) ⇒ Object
Execute a command asynchronously.
- #pending ⇒ Object
Instance Method Details
#execute(command, *bind) ⇒ Object
Execute a command asynchronously.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/swift/adapter/eventmachine.rb', line 43 def execute command, *bind raise RuntimeError, 'Command already in progress' unless pending.empty? record, command = command, bind.shift if command.kind_of?(Class) && command < Record pending << [Time.now, command, bind] query(command, *bind) ::EM::DefaultDeferrable.new.tap do |defer| ::EM.watch(fileno, Handler, self, record, defer) {|c| c.notify_readable = true} end end |
#pending ⇒ Object
55 56 57 |
# File 'lib/swift/adapter/eventmachine.rb', line 55 def pending @pending ||= [] end |