Sha256: d418aa79aeb9af3dd958ece868337d3af5a4b351e95ea21a35d1ba12b0d532ed

Contents?: true

Size: 679 Bytes

Versions: 32

Compression:

Stored size: 679 Bytes

Contents

# encoding: utf-8

require 'mysql2/em'
require 'fiber'

module Mysql2
  module EM
    module Fiber
      class Client < ::Mysql2::EM::Client
        def query(sql, opts={})
          if ::EM.reactor_running?
            deferable = super(sql, opts)

            fiber = ::Fiber.current
            deferable.callback do |result|
              fiber.resume(result)
            end
            deferable.errback do |err|
              fiber.resume(err)
            end
            ::Fiber.yield.tap do |result|
              raise result if result.is_a?(::Exception)
            end
          else
            super(sql, opts)
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
mysql2-0.2.19b6 lib/mysql2/em_fiber.rb
mysql2-0.2.19b5 lib/mysql2/em_fiber.rb
mysql2-0.2.19b4 lib/mysql2/em_fiber.rb
mysql2-0.2.19b3 lib/mysql2/em_fiber.rb
mysql2-0.2.19b2 lib/mysql2/em_fiber.rb
mysql2-0.2.19b1 lib/mysql2/em_fiber.rb
mysql2-0.2.18-x86-mswin32-60 lib/mysql2/em_fiber.rb
mysql2-0.2.18-x86-mingw32 lib/mysql2/em_fiber.rb
mysql2-0.2.18 lib/mysql2/em_fiber.rb
mysql2-0.2.17 lib/mysql2/em_fiber.rb
mysql2-0.2.16 lib/mysql2/em_fiber.rb
mysql2-0.2.16-x86-mswin32-60 lib/mysql2/em_fiber.rb
mysql2-0.2.16-x86-mingw32 lib/mysql2/em_fiber.rb
mysql2-0.2.15-x86-mswin32-60 lib/mysql2/em_fiber.rb
mysql2-0.2.14 lib/mysql2/em_fiber.rb
mysql2-0.3.7 lib/mysql2/em_fiber.rb
mysql2-0.2.13 lib/mysql2/em_fiber.rb
mysql2-0.2.12 lib/mysql2/em_fiber.rb
mysql2-0.3.6 lib/mysql2/em_fiber.rb
mysql2-0.2.11 lib/mysql2/em_fiber.rb