@@ -42,16 +42,6 @@ def synchronize
42
42
43
43
private
44
44
45
- # wait until another thread calls #signal or #broadcast,
46
- # spurious wake-ups can happen.
47
- # @param [Numeric, nil] timeout in seconds, `nil` means no timeout
48
- # @return [self]
49
- # @note intended to be made public if required in child classes
50
- def wait ( timeout = nil )
51
- synchronize { ns_wait ( timeout ) }
52
- self
53
- end
54
-
55
45
# initialization of the object called inside synchronize block
56
46
def ns_initialize ( *args , &block )
57
47
end
@@ -61,32 +51,14 @@ def ns_initialize(*args, &block)
61
51
# @param [Numeric, nil] timeout in seconds, `nil` means no timeout
62
52
# @yield condition to be met
63
53
# @yieldreturn [true, false]
64
- # @return [true, false]
65
- # @note intended to be made public if required in child classes
66
- def wait_until ( timeout = nil , &condition )
67
- synchronize { ns_wait_until ( timeout , &condition ) }
68
- end
69
-
70
- # signal one waiting thread
71
- # @return [self]
72
- # @note intended to be made public if required in child classes
73
- def signal
74
- synchronize { ns_signal }
75
- self
76
- end
77
-
78
- # broadcast to all waiting threads
79
- # @return [self]
80
- # @note intended to be made public if required in child classes
81
- def broadcast
82
- synchronize { ns_broadcast }
83
- self
84
- end
85
-
54
+ # @return [true, false] if condition met
86
55
# @note only to be used inside synchronized block
87
- # @yield condition
88
- # @return [true, false]
89
- # see #wait_until
56
+ # @note to provide direct access to this method in a descendant add method
57
+ # ```
58
+ # def wait_until(timeout = nil, &condition)
59
+ # synchronize { ns_wait_until(timeout, &condition) }
60
+ # end
61
+ # ```
90
62
def ns_wait_until ( timeout , &condition )
91
63
if timeout
92
64
wait_until = Concurrent . monotonic_time + timeout
@@ -104,23 +76,44 @@ def ns_wait_until(timeout, &condition)
104
76
end
105
77
end
106
78
107
- # @note only to be used inside synchronized block
79
+ # Wait until another thread calls #signal or #broadcast,
80
+ # spurious wake-ups can happen.
81
+ #
82
+ # @param [Numeric, nil] timeout in seconds, `nil` means no timeout
108
83
# @return [self]
109
- # @see #wait
84
+ # @note only to be used inside synchronized block
85
+ # @note to provide direct access to this method in a descendant add method
86
+ # ```
87
+ # def wait(timeout = nil)
88
+ # synchronize { ns_wait(timeout) }
89
+ # end
90
+ # ```
110
91
def ns_wait ( timeout = nil )
111
92
raise NotImplementedError
112
93
end
113
94
114
- # @note only to be used inside synchronized block
95
+ # Signal one waiting thread
115
96
# @return [self]
116
- # @see #signal
97
+ # @note only to be used inside synchronized block
98
+ # @note to provide direct access to this method in a descendant add method
99
+ # ```
100
+ # def signal
101
+ # synchronize { ns_signal }
102
+ # end
103
+ # ```
117
104
def ns_signal
118
105
raise NotImplementedError
119
106
end
120
107
121
- # @note only to be used inside synchronized block
108
+ # Broadcast to all waiting threads
122
109
# @return [self]
123
- # @see #broadcast
110
+ # @note only to be used inside synchronized block
111
+ # @note to provide direct access to this method in a descendant add method
112
+ # ```
113
+ # def broadcast
114
+ # synchronize { ns_broadcast }
115
+ # end
116
+ # ```
124
117
def ns_broadcast
125
118
raise NotImplementedError
126
119
end
0 commit comments