diff --git a/pom.xml b/pom.xml index b58803623..f57e64e00 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 2.3.1 ${local.development} - ${project.name}-${project.version} + ${project.name} diff --git a/src/main/java/org/cyberpwn/phantom/ChanneledExecutivePoolController.java b/src/main/java/org/cyberpwn/phantom/ChanneledExecutivePoolController.java index bd6bfbe9e..f308c6983 100644 --- a/src/main/java/org/cyberpwn/phantom/ChanneledExecutivePoolController.java +++ b/src/main/java/org/cyberpwn/phantom/ChanneledExecutivePoolController.java @@ -42,6 +42,8 @@ public void fire(String channel, ExecutiveIterator it) pools.put(channel, new ExecutivePool((double) 1, 0)); } + pools.get(channel).add(it); + s("Funneled " + C.LIGHT_PURPLE + F.f(it.size()) + C.GREEN + " opterations into " + C.AQUA + channel + C.LIGHT_PURPLE + " " + F.f(pools.get(channel).size()) + C.GREEN + " total."); } } diff --git a/src/main/java/org/cyberpwn/phantom/Phantom.java b/src/main/java/org/cyberpwn/phantom/Phantom.java index 79e2f70e4..80344930e 100644 --- a/src/main/java/org/cyberpwn/phantom/Phantom.java +++ b/src/main/java/org/cyberpwn/phantom/Phantom.java @@ -4,17 +4,20 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.cyberpwn.phantom.construct.PhantomPlugin; -import org.cyberpwn.phantom.test.TestController; +import org.cyberpwn.phantom.sync.ExecutiveIterator; public class Phantom extends PhantomPlugin { private static Phantom instance; + private ChanneledExecutivePoolController channeledExecutivePoolController; private TestController testController; public void enable() { testController = new TestController(this); + channeledExecutivePoolController = new ChanneledExecutivePoolController(this); register(testController); + register(channeledExecutivePoolController); instance = this; } @@ -22,6 +25,16 @@ public void disable() { } + + public static void schedule(String channel, ExecutiveIterator it) + { + instance.channeledExecutivePoolController.fire(channel, it); + } + + public static void schedule(ExecutiveIterator it) + { + instance.channeledExecutivePoolController.fire("default", it); + } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) diff --git a/src/main/java/org/cyberpwn/phantom/test/TestController.java b/src/main/java/org/cyberpwn/phantom/TestController.java similarity index 70% rename from src/main/java/org/cyberpwn/phantom/test/TestController.java rename to src/main/java/org/cyberpwn/phantom/TestController.java index 068fa7961..f2bfb45c6 100644 --- a/src/main/java/org/cyberpwn/phantom/test/TestController.java +++ b/src/main/java/org/cyberpwn/phantom/TestController.java @@ -1,7 +1,8 @@ -package org.cyberpwn.phantom.test; +package org.cyberpwn.phantom; import java.io.File; import java.io.IOException; +import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -12,6 +13,8 @@ import org.cyberpwn.phantom.construct.Controller; import org.cyberpwn.phantom.lang.GList; import org.cyberpwn.phantom.lang.GMap; +import org.cyberpwn.phantom.sync.ExecutiveIterator; +import org.cyberpwn.phantom.sync.ExecutiveRunnable; public class TestController extends Controller { @@ -23,6 +26,46 @@ public TestController(Controllable parentController) tests = new GMap(); + tests.put("channel-pool", new Runnable() + { + @Override + public void run() + { + GList k = new GList(); + GList v = new GList(); + + for(int i = 0; i < 10240008 * Math.random(); i++) + { + k.add(UUID.randomUUID().toString()); + } + + v.qadd("alpha").qadd("beta").qadd("charlie").qadd("delta"); + + Phantom.schedule(new ExecutiveIterator(k.copy(), new ExecutiveRunnable() + { + public void run() + { + while(Math.random() < 0.6) + { + UUID.randomUUID(); + Math.sqrt(Math.sqrt(Math.random())); + } + + if(Math.random() < 0.001) + { + Phantom.schedule(v.pickRandom(), new ExecutiveIterator(k.copy(), new ExecutiveRunnable() + { + public void run() + { + + } + })); + } + } + })); + } + }); + tests.put("cluster-write", new Runnable() { @Override diff --git a/src/main/java/org/cyberpwn/phantom/sync/ExecutiveIterator.java b/src/main/java/org/cyberpwn/phantom/sync/ExecutiveIterator.java index 7f4751755..2e53f40ea 100644 --- a/src/main/java/org/cyberpwn/phantom/sync/ExecutiveIterator.java +++ b/src/main/java/org/cyberpwn/phantom/sync/ExecutiveIterator.java @@ -3,26 +3,18 @@ import java.util.Iterator; import java.util.List; -import com.google.common.collect.Iterators; - public class ExecutiveIterator implements Iterator { private Iterator it; private ExecutiveRunnable runnable; private Boolean cancelled; private T repeated; - - public ExecutiveIterator(Iterator it, ExecutiveRunnable runnable) - { - this.it = it; - this.runnable = runnable; - this.cancelled = false; - this.repeated = null; - } + private Integer size; public ExecutiveIterator(List it, ExecutiveRunnable runnable) { this.it = it.iterator(); + this.size = it.size(); this.runnable = runnable; this.cancelled = false; this.repeated = null; @@ -71,7 +63,7 @@ public T next() public int size() { - return Iterators.size(it); + return size; } public boolean isCancelled() diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5aab9b4c2..2761f1498 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: Phantom main: org.cyberpwn.phantom.Phantom -version: 1.1 +version: 1.2 commands: phantom: aliases: [ph, p, phan, pha] \ No newline at end of file