Class: Proc

Inherits:
Object show all
Defined in:
lib/fOOrth/library/fiber_library.rb,
lib/fOOrth/library/procedure_library.rb

Overview

A helper method in the Proc class for fOOrth threads.

Instance Method Summary collapse

Instance Method Details

#do_thread_start(vm, vm_name) ⇒ Object

Do the mechanics of starting a thread.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fOOrth/library/procedure_library.rb', line 51

def do_thread_start(vm, vm_name)
  block, interlock = self, Queue.new

  result = Thread.new(vm.foorth_copy(vm_name)) do |vm_copy|

    begin
      self.foorth_init(vm_copy.compiler_reset.connect_vm_to_thread)
    ensure
      interlock.push(:ready)
    end

    vm_copy.instance_exec(vm_copy, &block)
  end

  interlock.pop
  result
end

#to_foorth_fiberObject

Convert this procedure to a fiber.



120
121
122
# File 'lib/fOOrth/library/fiber_library.rb', line 120

def to_foorth_fiber
  XfOOrth::XfOOrth_Fiber.new(&self)
end