module Ballast

A collection of base utilities for web frameworks.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

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 choosealicense.com/licenses/mit.

A collection of base utilities for web frameworks.

Public Class Methods

in_em_thread(start_reactor = false, &block) click to toggle source

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

@param start_reactor [Boolean] If start a EM::Synchrony reactor if none is running. @param block [Proc] The block to run.

# File lib/ballast.rb, line 38
def self.in_em_thread(start_reactor = false, &block)
  if EM.reactor_running?
    run_in_thread(&block)
  elsif start_reactor
    EM.synchrony do
      Ballast.in_em_thread(&block)
      EM.stop
    end
  else
    block.call
  end
end