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.



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

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

Instance Attribute Details

#flagObject (readonly)

Returns the value of attribute flag.



8
9
10
# File 'lib/jekyll/utils/thread_event.rb', line 8

def flag
  @flag
end

Instance Method Details

#setObject



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

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

#waitObject



24
25
26
27
28
# File 'lib/jekyll/utils/thread_event.rb', line 24

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