Class: MultiForkr
- Inherits:
-
Object
- Object
- MultiForkr
- Defined in:
- lib/multi_forkr.rb
Instance Attribute Summary collapse
-
#child_defs ⇒ Object
readonly
Child Process Definitions.
-
#child_sets ⇒ Object
readonly
Child process pids.
-
#master_pid ⇒ Fixnum
readonly
The PID of the Forkr master.
Instance Method Summary collapse
-
#initialize(forklets) ⇒ MultiForkr
constructor
A new instance of MultiForkr.
-
#run ⇒ nil
Start the master, and spawn workers.
Constructor Details
#initialize(forklets) ⇒ MultiForkr
Returns a new instance of MultiForkr.
16 17 18 19 20 21 |
# File 'lib/multi_forkr.rb', line 16 def initialize(forklets) @child_defs = forklets @master_pid = $$ @child_sets = Hash.new { |h, k| h[k] = Array.new } @in_shutdown = false end |
Instance Attribute Details
#child_defs ⇒ Object (readonly)
Child Process Definitions
9 10 11 |
# File 'lib/multi_forkr.rb', line 9 def child_defs @child_defs end |
#child_sets ⇒ Object (readonly)
Child process pids.
13 14 15 |
# File 'lib/multi_forkr.rb', line 13 def child_sets @child_sets end |
#master_pid ⇒ Fixnum (readonly)
The PID of the Forkr master
5 6 7 |
# File 'lib/multi_forkr.rb', line 5 def master_pid @master_pid end |
Instance Method Details
#run ⇒ nil
Start the master, and spawn workers
25 26 27 28 29 30 31 32 |
# File 'lib/multi_forkr.rb', line 25 def run @inbound, @outbound = IO.pipe Signal.trap('CHLD') { dead_child } Signal.trap('INT') { interrupt } Signal.trap('TERM') { shutdown } Signal.trap('QUIT') { core_dump_quit } master_loop end |