class Rx::ImmediateScheduler::AsyncLockScheduler

Public Class Methods

new() click to toggle source
# File lib/rx/concurrency/immediate_scheduler.rb, line 33
def initialize
    @gate = nil
end

Public Instance Methods

schedule_relative_with_state(state, due_time, action) click to toggle source
# File lib/rx/concurrency/immediate_scheduler.rb, line 49
def schedule_relative_with_state(state, due_time, action) 
  return self.schedule_with_state state, action if due_time <= 0

  m = SingleAssignmentSubscription.new

  timer = Time.new

  @gate = AsyncLock.new if @gate.nil?

  @gate.wait do
    sleep_time = Time.new - timer
    sleep sleep_time if sleep_time > 0
    m.subscription = action.call self, state unless m.unsubscribed?
  end

  m
end
schedule_with_state(state, action) click to toggle source
# File lib/rx/concurrency/immediate_scheduler.rb, line 37
def schedule_with_state(state, action)
  m = SingleAssignmentSubscription.new

  @gate = AsyncLock.new if @gate.nil?

  @gate.wait do
    m.subscription = action.call self, state unless m.unsubscribed?
  end

  m
end