Class: Jekyll::Utils::ThreadEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/utils/thread_event.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeThreadEvent

Returns a new instance of ThreadEvent.



12
13
14
15
16
# File 'lib/jekyll/utils/thread_event.rb', line 12

def initialize
  @lock = Mutex.new
  @cond = ConditionVariable.new
  @flag = false
end

Instance Attribute Details

#flagObject (readonly)

Returns the value of attribute flag.



10
11
12
# File 'lib/jekyll/utils/thread_event.rb', line 10

def flag
  @flag
end

Instance Method Details

#setObject



18
19
20
21
22
23
24
# File 'lib/jekyll/utils/thread_event.rb', line 18

def set
  @lock.synchronize do
    yield if block_given?
    @flag = true
    @cond.broadcast
  end
end

#waitObject



26
27
28
29
30
31
32
# File 'lib/jekyll/utils/thread_event.rb', line 26

def wait
  @lock.synchronize do
    unless @flag
      @cond.wait(@lock)
    end
  end
end