lib/em-synchrony/mongo.rb in em-synchrony-0.3.0.beta.1 vs lib/em-synchrony/mongo.rb in em-synchrony-1.0.0

- old
+ new

@@ -9,6 +9,24 @@ class Mongo::Connection TCPSocket = ::EventMachine::Synchrony::TCPSocket Mutex = ::EventMachine::Synchrony::Thread::Mutex ConditionVariable = ::EventMachine::Synchrony::Thread::ConditionVariable end -end + + class Mongo::Pool + TCPSocket = ::EventMachine::Synchrony::TCPSocket + Mutex = ::EventMachine::Synchrony::Thread::Mutex + ConditionVariable = ::EventMachine::Synchrony::Thread::ConditionVariable + end + + class EventMachine::Synchrony::MongoTimeoutHandler + def self.timeout(op_timeout, ex_class, &block) + f = Fiber.current + timer = EM::Timer.new(op_timeout) { f.resume(nil) } + res = block.call + timer.cancel + res + end + end + + Mongo::TimeoutHandler = EventMachine::Synchrony::MongoTimeoutHandler +end \ No newline at end of file