class IOPromise::Dalli::DalliPromise
Attributes
key[R]
Public Class Methods
new(server = nil, key = nil)
click to toggle source
Calls superclass method
# File lib/iopromise/dalli/promise.rb, line 10 def initialize(server = nil, key = nil) super() # when created from a 'then' call, initialize nothing return if server.nil? || key.nil? @server = server @key = key @start_time = nil ::IOPromise::ExecutorContext.current.register(self) end
Public Instance Methods
execute_pool()
click to toggle source
# File lib/iopromise/dalli/promise.rb, line 31 def execute_pool return @pool if defined?(@pool) if defined?(@server) @pool = DalliExecutorPool.for(@server) else @pool = nil end end
in_select_loop()
click to toggle source
# File lib/iopromise/dalli/promise.rb, line 40 def in_select_loop if @start_time.nil? @start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) end end
timeout?()
click to toggle source
# File lib/iopromise/dalli/promise.rb, line 54 def timeout? return false if @start_time.nil? timeout_remaining <= 0 end
timeout_remaining()
click to toggle source
# File lib/iopromise/dalli/promise.rb, line 46 def timeout_remaining now = Process.clock_gettime(Process::CLOCK_MONOTONIC) elapsed = now - @start_time remaining = @server.options[:socket_timeout] - elapsed return 0 if remaining < 0 remaining end
wait()
click to toggle source
Calls superclass method
# File lib/iopromise/dalli/promise.rb, line 23 def wait unless defined?(@server) super else ::IOPromise::ExecutorContext.current.wait_for_all_data(end_when_complete: self) end end