Class | OpenWFE::ReserveExpression |
In: |
lib/openwfe/expressions/fe_reserve.rb
|
Parent: | FlowExpression |
The ‘reserve’ expression ensures that its nested child expression executes while a reserved mutex is set.
Thus
concurrence do reserve :mutex => :m0 do sequence do participant :alpha participant :bravo end end reserve :mutex => :m0 do participant :charly end participant :delta end
The sequence will not but run while the participant charly is active and vice versa. The participant delta is not concerned.
The mutex is a regular variable name, thus a mutex named "//toto" could be used to prevent segments of totally different process instances from running.
applied_workitem | [RW] | An instance variable for storing the applied workitem if the ‘reserve’ cannot be entered immediately. |
mutex_name | [RW] | The name of the mutex this expressions uses. It‘s a variable name, that means it can be prefixed with {nothing} (local scope), ’/’ (process scope) and ’//’ (engine / global scope). |
# File lib/openwfe/expressions/fe_reserve.rb, line 96 96: def apply (workitem) 97: 98: return reply_to_parent(workitem) \ 99: if @children.size < 1 100: 101: @mutex_name = lookup_string_attribute :mutex, workitem 102: 103: FlowMutex.synchronize do 104: 105: mutex = 106: lookup_variable(@mutex_name) || FlowMutex.new(@mutex_name) 107: 108: mutex.register self, workitem 109: end 110: end