123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::Promises::ScheduledPromise

Constant Summary

InternalStates - Included

PENDING, RESERVED, RESOLVED

Class Attribute Summary

Class Method Summary

AbstractPromise - Inherited

Synchronization::Object - Inherited

.atomic_attribute?, .atomic_attributes,
.attr_atomic

Creates methods for reading and writing to a instance variable with volatile (Java) semantic as .attr_volatile does.

.attr_volatile

Creates methods for reading and writing (as attr_accessor does) to a instance variable with volatile (Java) semantic.

.ensure_safe_initialization_when_final_fields_are_present

For testing purposes, quite slow.

.new

Has to be called by children.

.safe_initialization!, .define_initialize_atomic_fields

Synchronization::AbstractObject - Inherited

Instance Method Summary

Constructor Details

.new(default_executor, intended_time) ⇒ ScheduledPromise (private)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 2125

def initialize(default_executor, intended_time)
  super Event.new(self, default_executor)

  @IntendedTime = intended_time

  in_seconds = begin
    now           = Time.now
    schedule_time = if @IntendedTime.is_a? Time
                      @IntendedTime
                    else
                      now + @IntendedTime
                    end
    [0, schedule_time.to_f - now.to_f].max
  end

  Concurrent.global_timer_set.post(in_seconds) do
    @Future.resolve_with RESOLVED
  end
end

Instance Method Details

#inspect

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 2119

def inspect
  "#{to_s[0..-2]} intended_time: #{@IntendedTime}>"
end

#intended_time

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 2115

def intended_time
  @IntendedTime
end