Class: Minx::Process
- Inherits:
-
Object
- Object
- Minx::Process
- Defined in:
- lib/minx/process.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ Process
constructor
A new instance of Process.
-
#resume ⇒ Object
Resume the process.
-
#spawn ⇒ Object
Spawn the process.
Constructor Details
#initialize(&block) ⇒ Process
Returns a new instance of Process.
4 5 6 7 |
# File 'lib/minx/process.rb', line 4 def initialize(&block) raise ArgumentError unless block_given? @fiber = Fiber.new { block.call } end |
Instance Method Details
#resume ⇒ Object
Resume the process.
This yields execution to the process.
20 21 22 |
# File 'lib/minx/process.rb', line 20 def resume @fiber.resume end |
#spawn ⇒ Object
Spawn the process.
The process will immediately take over execution, and the current fiber will yield.
13 14 15 |
# File 'lib/minx/process.rb', line 13 def spawn @fiber.resume end |