File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change
1
+ require 'concurrent/synchronization'
2
+
1
3
module Concurrent
2
4
3
5
# Clock that cannot be set and represents monotonic time since
4
6
# some unspecified starting point.
5
7
# @!visibility private
6
- GLOBAL_MONOTONIC_CLOCK = Class . new {
8
+ GLOBAL_MONOTONIC_CLOCK = Class . new ( Synchronization :: Object ) {
7
9
8
10
if defined? ( Process ::CLOCK_MONOTONIC )
9
11
# @!visibility private
@@ -17,17 +19,9 @@ def get_time
17
19
end
18
20
else
19
21
20
- require 'thread'
21
-
22
- # @!visibility private
23
- def initialize
24
- @mutex = Mutex . new
25
- @last_time = Time . now . to_f
26
- end
27
-
28
22
# @!visibility private
29
23
def get_time
30
- @mutex . synchronize do
24
+ synchronize do
31
25
now = Time . now . to_f
32
26
if @last_time < now
33
27
@last_time = now
@@ -36,6 +30,13 @@ def get_time
36
30
end
37
31
end
38
32
end
33
+
34
+ protected
35
+
36
+ # @!visibility private
37
+ def ns_initialize
38
+ @last_time = Time . now . to_f
39
+ end
39
40
end
40
41
} . new
41
42
private_constant :GLOBAL_MONOTONIC_CLOCK
You can’t perform that action at this time.
0 commit comments