class Engine

Public Class Methods

new(scheduler) click to toggle source
# File lib/delve/engine.rb, line 3
def initialize scheduler
  raise 'Cannot initialize engine when scheduler is nil' unless scheduler
  @scheduler = scheduler
  @lock = 1
end

Public Instance Methods

lock() click to toggle source
# File lib/delve/engine.rb, line 13
def lock
  @lock += 1
end
locked?() click to toggle source
# File lib/delve/engine.rb, line 9
def locked?
  @lock > 0
end
unlock() click to toggle source
# File lib/delve/engine.rb, line 17
def unlock
  @lock -= 1

  while !locked? do
    actor = @scheduler.next
    if !actor
      lock
      break
    end
    actor.act
  end
end