Class: Mysql2::Fibered::Client
- Defined in:
- lib/active_record/connection_adapters/em_mysql2_adapter.rb
Defined Under Namespace
Modules: Watcher
Constant Summary
Constants inherited from Client
Client::CHARSET_MAP, Client::MYSQL_CHARSET_MAP
Instance Attribute Summary
Attributes inherited from Client
Instance Method Summary collapse
Methods inherited from Client
#affected_rows, #async_result, #close, default_query_options, encoding_from_charset, encoding_from_charset_code, #escape, #info, #initialize, #last_id, #server_info, #socket
Constructor Details
This class inherits a constructor from Mysql2::Client
Instance Method Details
#query(sql, opts = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_record/connection_adapters/em_mysql2_adapter.rb', line 44 def query(sql, opts={}) if EM.reactor_running? super(sql, opts.merge(:async => true)) deferable = ::EM::DefaultDeferrable.new ::EM.watch(self.socket, Watcher, self, deferable).notify_readable = true fiber = Fiber.current deferable.callback do |result| fiber.resume(result) end deferable.errback do |err| fiber.resume(err) end Fiber.yield else super(sql, opts) end end |