activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1141222 - /activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala
Date Wed, 29 Jun 2011 19:51:16 GMT
Author: chirino
Date: Wed Jun 29 19:51:16 2011
New Revision: 1141222

URL: http://svn.apache.org/viewvc?rev=1141222&view=rev
Log:
Fixes https://issues.apache.org/jira/browse/APLO-57 : Track desired service state so you can
stop a service which is starting (calls stop once started)

Modified:
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala?rev=1141222&r1=1141221&r2=1141222&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala
Wed Jun 29 19:51:16 2011
@@ -18,6 +18,7 @@ package org.apache.activemq.apollo.util
 
 import org.fusesource.hawtdispatch.DispatchQueue
 import org.fusesource.hawtdispatch._
+import collection.mutable.ListBuffer
 
 object BaseService extends Log
 
@@ -73,10 +74,10 @@ trait BaseService extends Service with D
   protected var _serviceFailure:Exception = null
   def serviceFailure = _serviceFailure
 
-  private var pending_actions = List[Runnable]()
+  private val pending_actions = ListBuffer[Runnable]()
 
   final def start(on_completed:Runnable) = {
-    val start_task = ^{
+    def start_task:Runnable = ^{
       def do_start = {
         val state = new STARTING()
         state << on_completed
@@ -97,7 +98,7 @@ trait BaseService extends Service with D
       }
       def done = {
         pending_actions.foreach(dispatch_queue.execute _)
-        pending_actions = Nil
+        pending_actions.clear()
         if( on_completed!=null ) {
           on_completed.run
         }
@@ -118,14 +119,14 @@ trait BaseService extends Service with D
           error("Start should not be called from state: %s", state);
       }
     }
-    start_task |>>: dispatch_queue
+    start_task >>: dispatch_queue
   }
 
   final def stop(on_completed:Runnable) = {
-    val stop_task = ^{
+    def stop_task:Runnable = ^{
       def done = {
         pending_actions.foreach(dispatch_queue.execute _)
-        pending_actions = Nil
+        pending_actions.clear
         if( on_completed!=null ) {
           on_completed.run
         }
@@ -159,7 +160,7 @@ trait BaseService extends Service with D
           error("Stop should not be called from state: %s", state);
       }
     }
-    stop_task |>>: dispatch_queue
+    stop_task >>: dispatch_queue
   }
 
   protected def _start(on_completed:Runnable)



Mime
View raw message