@note Only two threads can be used with this Turnstile
because of the current implementation.
Public Class Methods
new()click to toggle source
Initialize the turnstile.
# File lib/listen/turnstile.rb, line 10definitialize# Until ruby offers semahpores, only queues can be used# to implement a turnstile.@q = Queue.newend
Public Instance Methods
signal()click to toggle source
Unblocks the waiting thread if there is one.
# File lib/listen/turnstile.rb, line 24defsignal@q.push:dummyif@q.num_waiting==1end
wait()click to toggle source
Blocks the current thread until a signal is received.
# File lib/listen/turnstile.rb, line 18defwait@q.popif@q.num_waiting==0end