JezK
Edit File: cdesc-CountDownLatch.ri
U:RDoc::NormalClass[iI"CountDownLatch:EFI"Concurrent::CountDownLatch;FI"!CountDownLatchImplementation;To:RDoc::Markup::Document:@parts[o;;[ o:RDoc::Markup::Paragraph;[I"&@!macro [attach] count_down_latch;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim;[I"XA synchronization object that allows one thread to wait on multiple other threads. ;TI"UThe thread that will wait creates a `CountDownLatch` and sets the initial value ;TI"W(normally equal to the number of other threads). The initiating thread passes the ;TI"Xlatch to the other threads then waits for the other threads by calling the `#wait` ;TI"Tmethod. Each of the other threads calls `#count_down` when done with its work. ;TI"WWhen the latch counter reaches zero the waiting thread is unblocked and continues ;TI"Ywith its work. A `CountDownLatch` can be used only once. Its value cannot be reset. ;T:@format0o; ;[I")@!macro count_down_latch_public_api ;TI"$@example Waiter and Decrementer;To;;[I"/latch = Concurrent::CountDownLatch.new(3) ;TI" ;TI"waiter = Thread.new do ;TI" latch.wait() ;TI" puts ("Waiter released") ;TI" end ;TI" ;TI"!decrementer = Thread.new do ;TI" sleep(1) ;TI" latch.count_down ;TI" puts latch.count ;TI" ;TI" sleep(1) ;TI" latch.count_down ;TI" puts latch.count ;TI" ;TI" sleep(1) ;TI" latch.count_down ;TI" puts latch.count ;TI" end ;TI" ;TI"'[waiter, decrementer].each(&:join);T;0: @fileI".lib/concurrent/atomic/count_down_latch.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[i 0o;;[ ; 0;0[@7I"Concurrent;FcRDoc::NormalModule