class RxRuby::DefaultScheduler

Represents an object that schedules units of work on the platform’s default scheduler.

Public Instance Methods

schedule_relative_with_state(state, due_time, action) click to toggle source

Schedules an action to be executed after dueTime

# File lib/rx_ruby/concurrency/default_scheduler.rb, line 33
def schedule_relative_with_state(state, due_time, action)
  raise 'action cannot be nil' unless action

  dt = Scheduler.normalize due_time
  return self.schedule_with_state state, action if dt == 0

  d = SingleAssignmentSubscription.new

  t = Thread.new do
    sleep dt
    Thread.new {
      d.subscription = action.call self, state unless d.unsubscribed?
    }
  end

  CompositeSubscription.new [d, Subscription.create { t.exit }]         
end
schedule_with_state(state, action) click to toggle source

Schedules an action to be executed.

# File lib/rx_ruby/concurrency/default_scheduler.rb, line 20
def schedule_with_state(state, action)
  raise 'action cannot be nil' unless action

  d = SingleAssignmentSubscription.new

  t = Thread.new do
    d.subscription = action.call self, state unless d.unsubscribed?
  end

  CompositeSubscription.new [d, Subscription.create { t.exit }]
end