HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/default/doc/concurrent-ruby-1.1.9/ri/Concurrent/Semaphore/cdesc-Semaphore.ri
U:RDoc::NormalClass[iI"Semaphore:ETI"Concurrent::Semaphore;TI"SemaphoreImplementation;To:RDoc::Markup::Document:@parts[o;;[
o:RDoc::Markup::Paragraph;[I"@!macro semaphore;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim;[I"HA counting semaphore. Conceptually, a semaphore maintains a set of
;TI"Dpermits. Each {#acquire} blocks if necessary until a permit is
;TI"Navailable, and then takes it. Each {#release} adds a permit, potentially
;TI"$releasing a blocking acquirer.
;TI"LHowever, no actual permit objects are used; the Semaphore just keeps a
;TI"9count of the number available and acts accordingly.
;T:@format0o;	;[I""@!macro semaphore_public_api ;TI"
@example;To;;[#I".semaphore = Concurrent::Semaphore.new(2)
;TI"
;TI"t1 = Thread.new do
;TI"  semaphore.acquire
;TI"*  puts "Thread 1 acquired semaphore"
;TI"	end
;TI"
;TI"t2 = Thread.new do
;TI"  semaphore.acquire
;TI"*  puts "Thread 2 acquired semaphore"
;TI"	end
;TI"
;TI"t3 = Thread.new do
;TI"  semaphore.acquire
;TI"*  puts "Thread 3 acquired semaphore"
;TI"	end
;TI"
;TI"t4 = Thread.new do
;TI"  sleep(2)
;TI"+  puts "Thread 4 releasing semaphore"
;TI"  semaphore.release
;TI"	end
;TI"
;TI"#[t1, t2, t3, t4].each(&:join)
;TI"
;TI"# prints:
;TI"## Thread 3 acquired semaphore
;TI"## Thread 2 acquired semaphore
;TI"$# Thread 4 releasing semaphore
;TI""# Thread 1 acquired semaphore;T;0:
@fileI"7lib/concurrent-ruby/concurrent/atomic/semaphore.rb;T:0@omit_headings_from_table_of_contents_below0;
0;0[[[[[I"
class;T[[:public[[:protected[[:private[[I"
instance;T[[;[[;[[;[[[U:RDoc::Context::Section[i0o;;[;
0;0[@>I"Concurrent;TcRDoc::NormalModule