Class: ThreadStorm::Sentinel

Inherits:
Object
  • Object
show all
Defined in:
lib/thread_storm/sentinel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSentinel

Returns a new instance of Sentinel.



7
8
9
10
11
# File 'lib/thread_storm/sentinel.rb', line 7

def initialize
  @lock = Monitor.new
  @e_cond = @lock.new_cond # execute condition
  @p_cond = @lock.new_cond # pop condition
end

Instance Attribute Details

#e_condObject (readonly)

Returns the value of attribute e_cond.



5
6
7
# File 'lib/thread_storm/sentinel.rb', line 5

def e_cond
  @e_cond
end

#p_condObject (readonly)

Returns the value of attribute p_cond.



5
6
7
# File 'lib/thread_storm/sentinel.rb', line 5

def p_cond
  @p_cond
end

Instance Method Details

#synchronizeObject



13
14
15
# File 'lib/thread_storm/sentinel.rb', line 13

def synchronize
  @lock.synchronize{ yield(@e_cond, @p_cond) }
end