Module: NeverBlock
- Defined in:
- lib/never_block.rb,
lib/never_block/pool/fiber_pool.rb,
lib/never_block/db/pooled_db_connection.rb,
lib/never_block/db/fibered_db_connection.rb,
lib/never_block/db/fibered_mysql_connection.rb,
lib/never_block/pool/fibered_connection_pool.rb,
lib/never_block/db/fibered_postgres_connection.rb
Defined Under Namespace
Modules: DB, Pool Classes: NBError
Class Method Summary collapse
- .event_loop_available? ⇒ Boolean
-
.neverblock(nb = true, &block) ⇒ Object
The given block will run its queries either in blocking or non-blocking mode based on the first parameter.
-
.neverblocking? ⇒ Boolean
Checks if we should be working in a non-blocking mode.
Class Method Details
.event_loop_available? ⇒ Boolean
83 84 85 |
# File 'lib/never_block.rb', line 83 def self.event_loop_available? defined?(EM) && EM.reactor_running? end |
.neverblock(nb = true, &block) ⇒ Object
The given block will run its queries either in blocking or non-blocking mode based on the first parameter
89 90 91 92 93 94 |
# File 'lib/never_block.rb', line 89 def self.neverblock(nb = true, &block) status = Fiber.current[:neverblock] Fiber.current[:neverblock] = nb block.call Fiber.current[:neverblock] = status end |