lib/pione/agent/basic-agent.rb in pione-0.3.2 vs lib/pione/agent/basic-agent.rb in pione-0.4.0

- old
+ new

@@ -122,11 +122,11 @@ # for wait_until_after method @__wait_until_after_mutex__ = Mutex.new @__wait_until_after_cv__ = Hash.new {|h, k| h[k] = ConditionVariable.new} end - # Start agent activity. + # Start the agent activity. def start unless @chain_threads.list.empty? raise TerminationError.new(self, states) end @@ -138,10 +138,16 @@ @chain_threads.enclose return self end + # Start the agent activity and wait the termination. + def start! + start + wait_until_terminated(nil) + end + # Fire the transtion with inputs. def transit(transition, transition_inputs) # wake up threads that wait by wait_until_before method if @__wait_until_before_cv__.has_key?(transition) @__wait_until_before_mutex__.synchronize do @@ -276,12 +282,12 @@ rescue TerminationError break # end loop after terminate transition end end rescue Exception => e - # throw the exception to command's runnning thread - if Global.command and Global.command.running_thread and Global.command.running_thread.alive? - Global.command.running_thread.raise e + # throw the exception to owner thread + if @__owner_thread__ and @__owner_thread__.alive? + @__owner_thread__.raise e else raise e end end end