lib/ruote/log/test_logger.rb in ruote-2.1.9 vs lib/ruote/log/test_logger.rb in ruote-2.1.10

- old
+ new

@@ -72,18 +72,20 @@ @log << msg check_waiting end - def wait_for (*interests) + def wait_for (interests) @waiting = [ Thread.current, interests ] check_waiting Thread.stop if @waiting + # and when this thread gets woken up, go on and return __result__ + Thread.current['__result__'] end # Debug only : dumps all the seen events to STDOUTS # @@ -129,44 +131,49 @@ false end end + FINAL_ACTIONS = %w[ terminated ceased error_intercepted ] + def check_interest (msg) - over = false - action = msg['action'] - Array(@waiting.last).each do |interest| + @waiting.last.each do |interest| - over = if interest.is_a?(Symbol) # participant + satisfied = if interest == :inactive - (action == 'dispatch' && msg['participant_name'] == interest.to_s) + (FINAL_ACTIONS.include?(action) && @context.worker.inactive?) - elsif interest.is_a?(Fixnum) + elsif interest == :empty - interest = interest - 1 - @waiting = [ @waiting.first, interest ] + (action == 'terminated' && @context.storage.empty?('expressions')) - #@debug ||= {} - #c = @debug[action] ||= 0 - #@debug[action] = c+1 - #p [ interest, @debug ] + elsif interest.is_a?(Symbol) # participant - (interest < 1) + (action == 'dispatch' && msg['participant_name'] == interest.to_s) + elsif interest.is_a?(Fixnum) + + @waiting[-1] = @waiting[-1] - [ interest ] + if (interest > 1) + @waiting[-1] << (interest - 1) + false + else + true + end + else # wfid - %w[ terminated ceased error_intercepted ].include?(action) && - msg['wfid'] == interest + (FINAL_ACTIONS.include?(action) && msg['wfid'] == interest) end - break if over + @waiting[-1] = @waiting[-1] - [ interest ] if satisfied end - over + @waiting.last.size < 1 end # <ESC>[{attr1};...;{attrn}m # # 0 Reset all attributes @@ -242,20 +249,22 @@ end action = msg['action'][0, 2] action = case msg['action'] when 'receive' then 'rc' + when 'dispatched' then 'dd' when 'dispatch_cancel' then 'dc' else action end action = case action when 'la' then color('4;32', action) when 'te' then color('4;31', action) when 'ce' then color('31', action) when 'ca' then color('31', action) when 'rc' then color('4;33', action) - when 'dc' then color('4;31', action) when 'di' then color('4;33', action) + when 'dd' then color('4;33', action) + when 'dc' then color('4;31', action) else action end color( @color,