class Jekyll::Utils::ThreadEvent
Based on the pattern and code from emptysqua.re/blog/an-event-synchronization-primitive-for-ruby/
Attributes
flag[R]
Public Class Methods
new()
click to toggle source
# File lib/jekyll/utils/thread_event.rb, line 12 def initialize @lock = Mutex.new @cond = ConditionVariable.new @flag = false end
Public Instance Methods
set() { || ... }
click to toggle source
# File lib/jekyll/utils/thread_event.rb, line 18 def set @lock.synchronize do yield if block_given? @flag = true @cond.broadcast end end
wait()
click to toggle source
# File lib/jekyll/utils/thread_event.rb, line 26 def wait @lock.synchronize do unless @flag @cond.wait(@lock) end end end