Module: Aw
- Defined in:
- lib/aw.rb,
lib/aw/fork.rb
Overview
Namespace for the Aw library.
Defined Under Namespace
Classes: Fork
Class Method Summary collapse
-
.fork!(&block) ⇒ #object_id
Runs the block inside a sub-process, and returns the computed value.
-
.fork?(&block) ⇒ Boolean
Runs the block inside a sub-process, and returns ‘true` if no exception is thrown.
Class Method Details
.fork!(&block) ⇒ #object_id
Runs the block inside a sub-process, and returns the computed value.
25 26 27 28 |
# File 'lib/aw.rb', line 25 def self.fork!(&block) read, write = ::IO.pipe Fork.new(read, write).call(&block) end |
.fork?(&block) ⇒ Boolean
Runs the block inside a sub-process, and returns ‘true` if no exception is thrown. Otherwise when an exception is raised, `false` is returned.
42 43 44 45 46 |
# File 'lib/aw.rb', line 42 def self.fork?(&block) pid = ::Process.fork(&block) _, status = ::Process.wait2(pid) status.success? end |