File tree Expand file tree Collapse file tree 3 files changed +57
-6
lines changed Expand file tree Collapse file tree 3 files changed +57
-6
lines changed Original file line number Diff line number Diff line change 1
1
language : ruby
2
2
3
- cache : bundler
4
-
5
3
rvm :
6
4
# start with the latest
7
5
- 2.4.0
8
6
- jruby-9.1.5.0
9
7
10
8
# older versions
11
9
- 2.3.3
12
- - 2.2
13
- - 2.1
14
- - 2.0
10
+ - 2.2.6
11
+ - 2.1.9
12
+ - 2.0.0
15
13
- 1.9.3
16
14
17
15
- jruby-9.0.5.0
52
50
global :
53
51
- JAVA_OPTS=-Xmx1024m
54
52
55
- before_script :
53
+ before_install :
56
54
- " echo $JAVA_OPTS"
55
+ - bundle update # temporary fix, not sure why it helps
57
56
58
57
script : if [[ -v TRUFFLE ]]; then support/test-truffle.sh; else RUBYOPT=-w bundle exec rake ci; fi
Original file line number Diff line number Diff line change @@ -13,6 +13,26 @@ module Concurrent
13
13
# `#reset` at any time once it has been set.
14
14
#
15
15
# @see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682655.aspx
16
+ # @example
17
+ # event = Concurrent::Event.new
18
+ #
19
+ # t1 = Thread.new do
20
+ # puts "t1 is waiting"
21
+ # event.wait(1)
22
+ # puts "event ocurred"
23
+ # end
24
+ #
25
+ # t2 = Thread.new do
26
+ # puts "t2 calling set"
27
+ # event.set
28
+ # end
29
+ #
30
+ # [t1, t2].each(&:join)
31
+ #
32
+ # # prints:
33
+ # # t2 calling set
34
+ # # t1 is waiting
35
+ # # event ocurred
16
36
class Event < Synchronization ::LockableObject
17
37
18
38
# Creates a new `Event` in the unset state. Threads calling `#wait` on the
Original file line number Diff line number Diff line change @@ -108,6 +108,38 @@ module Concurrent
108
108
# count of the number available and acts accordingly.
109
109
#
110
110
# @!macro semaphore_public_api
111
+ # @example
112
+ # semaphore = Concurrent::Semaphore.new(2)
113
+ #
114
+ # t1 = Thread.new do
115
+ # semaphore.acquire
116
+ # puts "Thread 1 acquired semaphore"
117
+ # end
118
+ #
119
+ # t2 = Thread.new do
120
+ # semaphore.acquire
121
+ # puts "Thread 2 acquired semaphore"
122
+ # end
123
+ #
124
+ # t3 = Thread.new do
125
+ # semaphore.acquire
126
+ # puts "Thread 3 acquired semaphore"
127
+ # end
128
+ #
129
+ # t4 = Thread.new do
130
+ # sleep(2)
131
+ # puts "Thread 4 releasing semaphore"
132
+ # semaphore.release
133
+ # end
134
+ #
135
+ # [t1, t2, t3, t4].each(&:join)
136
+ #
137
+ # # prints:
138
+ # # Thread 3 acquired semaphore
139
+ # # Thread 2 acquired semaphore
140
+ # # Thread 4 releasing semaphore
141
+ # # Thread 1 acquired semaphore
142
+ #
111
143
class Semaphore < SemaphoreImplementation
112
144
end
113
145
end
You can’t perform that action at this time.
0 commit comments