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 11language : ruby
22
3- cache : bundler
4-
53rvm :
64 # start with the latest
75 - 2.4.0
86 - jruby-9.1.5.0
97
108 # older versions
119 - 2.3.3
12- - 2.2
13- - 2.1
14- - 2.0
10+ - 2.2.6
11+ - 2.1.9
12+ - 2.0.0
1513 - 1.9.3
1614
1715 - jruby-9.0.5.0
5250 global :
5351 - JAVA_OPTS=-Xmx1024m
5452
55- before_script :
53+ before_install :
5654 - " echo $JAVA_OPTS"
55+ - bundle update # temporary fix, not sure why it helps
5756
5857script : 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
1313 # `#reset` at any time once it has been set.
1414 #
1515 # @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
1636 class Event < Synchronization ::LockableObject
1737
1838 # 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
108108 # count of the number available and acts accordingly.
109109 #
110110 # @!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+ #
111143 class Semaphore < SemaphoreImplementation
112144 end
113145end
You can’t perform that action at this time.
0 commit comments