### Home Classes Methods

### In Files

- lib/amqp/ext/emfork.rb

### Methods

- ::fork
- ::forks

### Class/Module Index

Quicksearch

- AMQP
- AMQP::BitSet
- AMQP::BlankSlate
- AMQP::Broker
- AMQP::Channel
- AMQP::ChannelClosedError
- AMQP::Client
- AMQP::Consumer
- AMQP::Error
- AMQP::Exchange
- AMQP::Header
- AMQP::IncompatibleOptionsError
- AMQP::IntAllocator
- AMQP::Integration
- AMQP::Integration::Rails
- AMQP::Logger
- AMQP::PossibleAuthenticationFailureError
- AMQP::Queue
- AMQP::RPC
- AMQP::RPC::Client
- AMQP::RPC::Server
- AMQP::Session
- AMQP::TCPConnectionFailed
- AMQP::Utilities
- AMQP::Utilities::EventLoopHelper
- AMQP::Utilities::ServerType
- MQ
- MQ::Exchange
- MQ::Logger
- MQ::Queue
- EM
- Object

No matching classes.

# EM

### Public Class Methods

fork(num = 1, &blk) click to toggle source

helper to fork off EM reactors @private

    # File lib/amqp/ext/emfork.rb, line 13
    def EM.fork num = 1, &blk
      unless @forks
        trap('CHLD') {
          pid = Process.wait
          p [:pid, pid, :died] if EMFORK
          block = @forks.delete(pid)
          EM.fork(1, &block)
        }

        trap('EXIT') {
          p [:pid, Process.pid, :exit] if EMFORK
          @forks.keys.each { |pid|
            p [:pid, Process.pid, :killing, pid] if EMFORK
            Process.kill('USR1', pid)
          }
        }

        @forks = {}
      end

      num.times do
        pid = EM.fork_reactor do
          p [:pid, Process.pid, :started] if EMFORK

          trap('USR1') { EM.stop_event_loop }
          trap('CHLD') {}
          trap('EXIT') {}

          blk.call
        end

        @forks[pid] = blk
        p [:children, EM.forks] if EMFORK
      end
    end

forks() click to toggle source

@private

    # File lib/amqp/ext/emfork.rb, line 50
    def EM.forks
      @forks ? @forks.keys : []
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.