| Class | OpenWFE::FlowMutex |
| In: |
lib/openwfe/expressions/fe_reserve.rb
|
| Parent: | Object |
| feis | [RW] | |
| mutex_name | [RW] |
# File lib/openwfe/expressions/fe_reserve.rb, line 149
149: def initialize (mutex_name)
150:
151: @mutex_name = mutex_name
152: @feis = []
153: end
Used by the ReserveExpression when looking up for a FlowMutex and registering into it.
# File lib/openwfe/expressions/fe_reserve.rb, line 201
201: def self.synchronize (&block)
202:
203: @@class_mutex.synchronize do
204:
205: block.call
206: end
207: end
# File lib/openwfe/expressions/fe_reserve.rb, line 155
155: def register (fexp, workitem)
156:
157: @feis << fexp.fei
158:
159: fexp.set_variable @mutex_name, self
160:
161: if @feis.size == 1
162: #
163: # immediately let the expression enter the critical section
164: #
165: fexp.store_itself
166: fexp.enter workitem
167: else
168: #
169: # later...
170: #
171: fexp.applied_workitem = workitem
172: fexp.store_itself
173: end
174: end
# File lib/openwfe/expressions/fe_reserve.rb, line 176
176: def release (releaser)
177:
178: next_fei = nil
179:
180: @@class_mutex.synchronize do
181:
182: current_fei = @feis.delete_at 0
183:
184: releaser.set_variable @mutex_name, self
185:
186: log.warn "release() BAD! c:#{current_fei} r:#{releaser.fei}" \
187: if releaser.fei != current_fei
188:
189: next_fei = @feis.first
190: end
191:
192: return unless next_fei
193:
194: releaser.get_expression_pool.fetch_expression(next_fei).enter
195: end