Created
September 13, 2014 16:18
-
-
Save nithril/1deb881ddaa88576b107 to your computer and use it in GitHub Desktop.
Reactor hangs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Environment env = new Environment(); | |
Reactor reactor = Reactors.reactor() | |
.env(env) | |
.dispatcher(Environment.THREAD_POOL) | |
.get(); | |
reactor.on(Selectors.$("worker"), new Consumer() { | |
@Override | |
void accept(Object o) { | |
println Thread.currentThread().getName() + " worker " + o | |
reactor.notify("orchestrator", Event.wrap("ok")) | |
println Thread.currentThread().getName() + " ok" | |
} | |
}) | |
reactor.on(Selectors.$("orchestrator"), new Consumer<Event>() { | |
AtomicInteger tasksCount; | |
@Override | |
void accept(Event event) { | |
if (event.getData() instanceof Integer) { | |
tasksCount = new AtomicInteger(event.getData()) | |
} | |
sendTask() | |
} | |
void sendTask() { | |
println Thread.currentThread().getName() + " sendTask "; | |
reactor.notify("worker", Event.wrap(tasksCount.decrementAndGet())) | |
} | |
}) | |
reactor.notify("orchestrator", Event.wrap(1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment