Module: ProcessShared::Mach
- Includes:
- Mach
- Defined in:
- lib/process_shared/mach.rb,
lib/process_shared/mach/semaphore.rb
Defined Under Namespace
Classes: Semaphore
Constant Summary
Constants included from Mach
Mach::KERN_SUCCESS, Mach::MSG_TIMEOUT_NONE, Mach::MsgType, Mach::PORT_NULL, Mach::PortRight, Mach::PortType, Mach::SpecialPort, Mach::SyncPolicy
Class Method Summary collapse
- .after_fork_child ⇒ Object
- .after_fork_parent(port) ⇒ Object
-
.shared_ports ⇒ Object
The set of ports that should be shared to forked child processes.
Methods included from Mach
Methods included from Mach::Types
Class Method Details
.after_fork_child ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/process_shared/mach.rb', line 16 def self.after_fork_child parent_port = Task.self.get_bootstrap_port # give parent permission to send to child's task port Task.self.copy_send(parent_port) # create a second port and give the parent permission to send port = Port.new port.insert_right(:make_send) port.copy_send(parent_port) # parent copies sem, mutex port permissions directly to child # task port # wait for parent to send orig bootstrap port orig_bootstrap = port.receive_right Task.self.set_special_port(:bootstrap, orig_bootstrap) end |
.after_fork_parent(port) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/process_shared/mach.rb', line 35 def self.after_fork_parent(port) child_task_port = port.receive_right shared_ports.each do |p| p.insert_right(:copy_send, :ipc_space => child_task_port) end child_port = port.receive_right ::Mach::bootstrap_port.copy_send(child_port) end |
.shared_ports ⇒ Object
The set of ports that should be shared to forked child processes.
FIXME: protect with (original ruby) mutex?
12 13 14 |
# File 'lib/process_shared/mach.rb', line 12 def self.shared_ports @shared_ports ||= Set.new end |