Class: Minx::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/minx/process.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Process

Returns a new instance of Process.

Raises:

  • (ArgumentError)


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

#resumeObject

Resume the process.

This yields execution to the process.



20
21
22
# File 'lib/minx/process.rb', line 20

def resume
  @fiber.resume
end

#spawnObject

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