File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ module MonitorMixin
98
98
# above calls while_wait and signal, this class should be documented.
99
99
#
100
100
101
- class ConditionVariable < :: ConditionVariable
101
+ class ConditionVariable
102
102
103
103
#
104
104
# Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
@@ -107,7 +107,7 @@ class ConditionVariable < ::ConditionVariable
107
107
# even if no other thread doesn't signal.
108
108
#
109
109
def wait ( timeout = nil )
110
- super ( @mon_mutex , timeout )
110
+ @cond . wait ( @mon_mutex , timeout )
111
111
end
112
112
113
113
#
@@ -128,9 +128,30 @@ def wait_until
128
128
end
129
129
end
130
130
131
+ #
132
+ # Wakes up the first thread in line waiting for this lock.
133
+ #
134
+ def signal
135
+ check_owner
136
+ @cond . signal
137
+ end
138
+
139
+ #
140
+ # Wakes up all threads waiting for this lock.
141
+ #
142
+ def broadcast
143
+ check_owner
144
+ @cond . broadcast
145
+ end
146
+
131
147
private
132
148
149
+ def check_owner
150
+ raise ThreadError , "current thread not owner" unless @mon_mutex . owned?
151
+ end
152
+
133
153
def initialize ( mutex )
154
+ @cond = ::ConditionVariable . new
134
155
@mon_mutex = mutex
135
156
end
136
157
end
You can’t perform that action at this time.
0 commit comments