Add method to remove reactions.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 4 Jan 2013 16:54:00 +0000 (17:54 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 4 Jan 2013 16:54:00 +0000 (17:54 +0100)
src/main/java/net/pterodactylus/reactor/engine/Engine.java

index 0fb3f18..7c15e5a 100644 (file)
@@ -78,6 +78,23 @@ public class Engine extends AbstractExecutionThreadService {
                }
        }
 
+       /**
+        * Removes the reaction with the given name.
+        *
+        * @param name
+        *            The name of the reaction to remove
+        */
+       public void removeReaction(String name) {
+               synchronized (reactions) {
+                       if (!reactions.containsKey(name)) {
+                               return;
+                       }
+                       Reaction reaction = reactions.remove(name);
+                       reactionExecutions.remove(reaction);
+                       reactions.notifyAll();
+               }
+       }
+
        //
        // ABSTRACTSERVICE METHODS
        //