class RxRuby::ScheduledItem
Represents a scheduled work item based on the materialization of an scheduler.schedule method call.
Attributes
due_time[R]
Public Class Methods
new(scheduler, state, due_time, &action)
click to toggle source
# File lib/rx_ruby/concurrency/scheduled_item.rb, line 14 def initialize(scheduler, state, due_time, &action) @scheduler = scheduler @state = state @action = action @due_time = due_time @subscription = SingleAssignmentSubscription.new end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/rx_ruby/concurrency/scheduled_item.rb, line 32 def <=>(other) return @due_time <=> other.due_time end
cancel()
click to toggle source
Cancels the work item by disposing the resource returned by invoke_core as soon as possible.
# File lib/rx_ruby/concurrency/scheduled_item.rb, line 37 def cancel @subscription.unsubscribe end
cancelled?()
click to toggle source
Gets whether the work item has received a cancellation request.
# File lib/rx_ruby/concurrency/scheduled_item.rb, line 23 def cancelled? @subscription.unsubscribed? end
invoke()
click to toggle source
Invokes the work item.
# File lib/rx_ruby/concurrency/scheduled_item.rb, line 28 def invoke @subscription.subscription = @action.call @scheduler, @state unless @subscription.unsubscribed? end