WIP: New state machine for message processing
[aquarium] / src / main / scala / gr / grnet / aquarium / store / memory / MemStoreProvider.scala
index 301db6d..2330c45 100644 (file)
@@ -185,12 +185,14 @@ extends StoreProvider
    *
    * Any exception is propagated to the caller. The underlying DB resources are properly disposed in any case.
    */
-  def foreachIMEventInOccurrenceOrder(userID: String)(f: (IMEventMsg) ⇒ Unit) = {
+  def foreachIMEventInOccurrenceOrder(userID: String)(f: (IMEventMsg) ⇒ Boolean) = {
+    var _shouldContinue = true
     for {
-      msg <- _imEvents
+      msg <- _imEvents if _shouldContinue
     } {
-      f(msg)
+      _shouldContinue = f(msg)
     }
+    _shouldContinue
   }
   //- IMEventStore