@@ -61,7 +61,7 @@ def ns_wait_until(timeout, &condition)
61
61
if timeout
62
62
wait_until = Concurrent . monotonic_time + timeout
63
63
while true
64
- now = Concurrent . monotonic_time
64
+ now = Concurrent . monotonic_time
65
65
condition_result = condition . call
66
66
return condition_result if now >= wait_until || condition_result
67
67
ns_wait wait_until - now
@@ -122,15 +122,15 @@ def ns_signal
122
122
123
123
class RubySynchronizedObject < AbstractSynchronizedObject
124
124
def initialize
125
- @__mutex__do_not_use_directly = Mutex . new
125
+ @__lock__do_not_use_directly = Mutex . new
126
126
@__condition__do_not_use_directly = ConditionVariable . new
127
127
end
128
128
129
129
def synchronize
130
- if @__mutex__do_not_use_directly . owned?
130
+ if @__lock__do_not_use_directly . owned?
131
131
yield
132
132
else
133
- @__mutex__do_not_use_directly . synchronize { yield }
133
+ @__lock__do_not_use_directly . synchronize { yield }
134
134
end
135
135
end
136
136
@@ -145,16 +145,36 @@ def ns_broadcast
145
145
end
146
146
147
147
def ns_wait ( timeout )
148
- @__condition__do_not_use_directly . wait @__mutex__do_not_use_directly , timeout
148
+ @__condition__do_not_use_directly . wait @__lock__do_not_use_directly , timeout
149
+ end
150
+ end
151
+
152
+ class Ruby19SynchronizedObject < RubySynchronizedObject
153
+ def initialize
154
+ @__lock__do_not_use_directly = Monitor . new
155
+ @__condition__do_not_use_directly = @__lock__do_not_use_directly . new_cond
156
+ end
157
+
158
+ def synchronize
159
+ @__lock__do_not_use_directly . synchronize { yield }
160
+ end
161
+
162
+ private
163
+
164
+ def ns_wait ( timeout )
165
+ @__condition__do_not_use_directly . wait timeout
149
166
end
150
167
end
151
168
152
169
# TODO add rbx implementation
153
170
SynchronizedObject = Class . new case
154
171
when Concurrent . on_jruby?
155
172
JavaSynchronizedObject
173
+ when Concurrent . on_cruby? && ( RUBY_VERSION . split ( '.' ) . map ( &:to_i ) <=> [ 1 , 9 , 3 ] ) >= 0
174
+ Ruby19SynchronizedObject
175
+ when Concurrent . on_cruby?
176
+ RubySynchronizedObject
156
177
else
157
178
RubySynchronizedObject
158
179
end
159
-
160
180
end
0 commit comments