We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c3d47b2 + c498ed6 commit c85b162Copy full SHA for c85b162
lib/concurrent/atomic/condition.rb
@@ -42,13 +42,13 @@ def initialize
42
# @param [Object] timeout nil means no timeout
43
# @return [Result]
44
def wait(mutex, timeout = nil)
45
- start_time = Time.now.to_f
+ start_time = clock_time
46
@condition.wait(mutex, timeout)
47
48
if timeout.nil?
49
Result.new(nil)
50
else
51
- Result.new(start_time + timeout - Time.now.to_f)
+ Result.new(start_time + timeout - clock_time)
52
end
53
54
@@ -66,5 +66,17 @@ def broadcast
66
true
67
68
69
+ private
70
+
71
+ if defined?(Process::CLOCK_MONOTONIC)
72
+ def clock_time
73
+ Process.clock_gettime Process::CLOCK_MONOTONIC
74
+ end
75
+ else
76
77
+ Time.now.to_f
78
79
80
81
82
0 commit comments