Class: IOPromise::Dalli::DalliPromise
- Inherits:
-
Base
- Object
- Promise
- Base
- IOPromise::Dalli::DalliPromise
show all
- Defined in:
- lib/iopromise/dalli/promise.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#beginning, #fulfill, #instrument, #notify_completion, #reject, #started_executing?
Constructor Details
#initialize(server = nil, key = nil) ⇒ DalliPromise
Returns a new instance of DalliPromise.
10
11
12
13
14
15
16
17
18
|
# File 'lib/iopromise/dalli/promise.rb', line 10
def initialize(server = nil, key = nil)
super()
@server = server
@key = key
@start_time = nil
::IOPromise::ExecutorContext.current.register(self) unless @server.nil? || @key.nil?
end
|
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
8
9
10
|
# File 'lib/iopromise/dalli/promise.rb', line 8
def key
@key
end
|
Instance Method Details
#execute_pool ⇒ Object
28
29
30
|
# File 'lib/iopromise/dalli/promise.rb', line 28
def execute_pool
DalliExecutorPool.for(@server)
end
|
#in_select_loop ⇒ Object
32
33
34
35
36
|
# File 'lib/iopromise/dalli/promise.rb', line 32
def in_select_loop
if @start_time.nil?
@start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
end
|
#timeout? ⇒ Boolean
46
47
48
49
|
# File 'lib/iopromise/dalli/promise.rb', line 46
def timeout?
return false if @start_time.nil?
timeout_remaining <= 0
end
|
#timeout_remaining ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/iopromise/dalli/promise.rb', line 38
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 ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/iopromise/dalli/promise.rb', line 20
def wait
if @server.nil? || @key.nil?
super
else
::IOPromise::ExecutorContext.current.wait_for_all_data(end_when_complete: self)
end
end
|