Skip to content

Commit

Permalink
Refactor Vert.x 3 event loop context to store context upon constructi…
Browse files Browse the repository at this point in the history
…on in order to prevent issues with calling runOnContext from a non-context thread.
  • Loading branch information
kuujo committed Jan 22, 2015
1 parent 69f4b67 commit 79e3546
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -15,6 +15,7 @@
*/
package net.kuujo.copycat.vertx;

import io.vertx.core.Context;
import io.vertx.core.Vertx;

import java.util.concurrent.Executor;
Expand All @@ -25,15 +26,15 @@
* @author <a href="http://github.com/kuujo">Jordan Halterman</a>
*/
public class VertxEventLoopExecutor implements Executor {
private final Vertx vertx;
private final Context context;

public VertxEventLoopExecutor(Vertx vertx) {
this.vertx = vertx;
this.context = vertx.getOrCreateContext();
}

@Override
public void execute(Runnable command) {
vertx.runOnContext(v -> command.run());
context.runOnContext(v -> command.run());
}

}

0 comments on commit 79e3546

Please sign in to comment.