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! ⇒ #object_id
Runs the block inside a sub-process, and returns the computed value.
-
.fork? ⇒ Boolean
Runs the block inside a sub-process, and returns ‘true` if no exception is thrown.
Class Method Details
.fork! ⇒ #object_id
Runs the block inside a sub-process, and returns the computed value.
23 24 25 26 |
# File 'lib/aw.rb', line 23 def self.fork!(&) read, write = ::IO.pipe Fork.new(read, write).call(&) end |
.fork? ⇒ 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.
38 39 40 41 42 |
# File 'lib/aw.rb', line 38 def self.fork?(&) pid = ::Process.fork(&) _, status = ::Process.wait2(pid) status.success? end |