Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/concurrent/atomic/condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def initialize
# @param [Object] timeout nil means no timeout
# @return [Result]
def wait(mutex, timeout = nil)
start_time = Time.now.to_f
start_time = clock_time
@condition.wait(mutex, timeout)

if timeout.nil?
Result.new(nil)
else
Result.new(start_time + timeout - Time.now.to_f)
Result.new(start_time + timeout - clock_time)
end
end

Expand All @@ -66,5 +66,17 @@ def broadcast
true
end

private

if defined?(Process::CLOCK_MONOTONIC)
def clock_time
Process.clock_gettime Process::CLOCK_MONOTONIC
end
else
def clock_time
Time.now.to_f
end
end

end
end