Skip to content

Commit 18d56fa

Browse files
committed
Improve documentation and unify default parameters
1 parent e78b4a5 commit 18d56fa

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/concurrent/synchronized_object.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
module Concurrent
22

3-
# Safe synchronization under any Ruby implementation
3+
# Safe synchronization under any Ruby implementation.
4+
# It provides methods like {#synchronize}, {#wait}, {#signal} and {#broadcast}.
45
# Provides a single layer which can improve its implementation over time without changes needed to
56
# the classes using it. Use {SynchronizedObject} not this abstract class.
6-
# @example
7+
#
8+
# @note this object does not support usage together with {Thread#wakeup} and {Thread#raise}.
9+
# `Thread#sleep` and `Thread#wakeup` will work as expected but mixing `SynchronizedObject#wait` and
10+
# `Thread#wakeup` will not work on all platforms.
11+
#
12+
# @see {Event} implementation as an example of this class use
13+
#
14+
# @example simple
715
# class AnClass < SynchronizedObject
816
# def initialize
917
# super
@@ -82,7 +90,7 @@ def ns_wait_until(timeout, &condition)
8290
end
8391

8492
# @return [self]
85-
def ns_wait(timeout)
93+
def ns_wait(timeout = nil)
8694
raise NotImplementedError
8795
end
8896

@@ -155,7 +163,7 @@ def ns_broadcast
155163
self
156164
end
157165

158-
def ns_wait(timeout)
166+
def ns_wait(timeout = nil)
159167
@__condition__do_not_use_directly.wait @__lock__do_not_use_directly, timeout
160168
self
161169
end
@@ -173,7 +181,7 @@ def synchronize
173181

174182
private
175183

176-
def ns_wait(timeout)
184+
def ns_wait(timeout = nil)
177185
@__condition__do_not_use_directly.wait timeout
178186
self
179187
end

0 commit comments

Comments
 (0)