Module: Ballast

Defined in:
lib/ballast/errors.rb,
lib/ballast.rb,
lib/ballast/version.rb,
lib/ballast/context.rb,
lib/ballast/operation.rb,
lib/ballast/configuration.rb,
lib/ballast/concerns/view.rb,
lib/ballast/concerns/ajax.rb,
lib/ballast/concerns/common.rb,
lib/ballast/operations_chain.rb,
lib/ballast/request_domain_matcher.rb,
lib/ballast/middlewares/default_host.rb,
lib/ballast/concerns/errors_handling.rb

Overview

This file is part of the ballast gem. Copyright (C) 2013 and above Shogun shogun@cowtech.it. Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.

Defined Under Namespace

Modules: Concerns, Errors, Middlewares, Version Classes: Configuration, Context, Operation, OperationsChain, RequestDomainMatcher

Class Method Summary (collapse)

Class Method Details

+ (Object) in_em_thread(&block)

If running under eventmachine, run the block in a thread of its threadpool using EM::Synchrony, otherwise run the block normally.

Parameters:

  • block (Proc)

    The block to run.



35
36
37
38
39
40
41
42
43
# File 'lib/ballast.rb', line 35

def self.in_em_thread(&block)
  if EM.reactor_running? then
    EM::Synchrony.defer do
      Fiber.new { block.call }.resume
    end
  else
    block.call
  end
end