File tree Expand file tree Collapse file tree 3 files changed +23
-18
lines changed Expand file tree Collapse file tree 3 files changed +23
-18
lines changed Original file line number Diff line number Diff line change
1
+ require 'concurrent/utility/clock_time'
2
+
1
3
module Concurrent
2
4
3
5
# Condition is a better implementation of standard Ruby ConditionVariable. The
@@ -42,13 +44,13 @@ def initialize
42
44
# @param [Object] timeout nil means no timeout
43
45
# @return [Result]
44
46
def wait ( mutex , timeout = nil )
45
- start_time = clock_time
47
+ start_time = Concurrent :: clock_time
46
48
@condition . wait ( mutex , timeout )
47
49
48
50
if timeout . nil?
49
51
Result . new ( nil )
50
52
else
51
- Result . new ( start_time + timeout - clock_time )
53
+ Result . new ( start_time + timeout - Concurrent :: clock_time )
52
54
end
53
55
end
54
56
@@ -65,21 +67,5 @@ def broadcast
65
67
@condition . broadcast
66
68
true
67
69
end
68
-
69
- private
70
-
71
- if defined? ( Process ::CLOCK_MONOTONIC )
72
- def clock_time
73
- Process . clock_gettime Process ::CLOCK_MONOTONIC
74
- end
75
- elsif RUBY_PLATFORM == 'java'
76
- def clock_time
77
- java . lang . System . nanoTime ( ) / 1_000_000_000.0
78
- end
79
- else
80
- def clock_time
81
- Time . now . to_f
82
- end
83
- end
84
70
end
85
71
end
Original file line number Diff line number Diff line change
1
+ require 'concurrent/utility/clock_time'
1
2
require 'concurrent/utility/processor_count'
2
3
require 'concurrent/utility/timeout'
3
4
require 'concurrent/utility/timer'
Original file line number Diff line number Diff line change
1
+ module Concurrent
2
+
3
+ if defined? ( Process ::CLOCK_MONOTONIC )
4
+ def clock_time
5
+ Process . clock_gettime ( Process ::CLOCK_MONOTONIC )
6
+ end
7
+ elsif RUBY_PLATFORM == 'java'
8
+ def clock_time
9
+ java . lang . System . nanoTime ( ) / 1_000_000_000.0
10
+ end
11
+ else
12
+ def clock_time
13
+ Time . now . to_f
14
+ end
15
+ end
16
+
17
+ module_function :clock_time
18
+ end
You can’t perform that action at this time.
0 commit comments