Not really a gotcha, it's just I let him sneak up on me.
return executor.submit(new Callable() { public Choice call() throws Exception { try { Choice result = player.brain.makeMove(round); gameEventListener.moveMade(player, result); return result; } finally { latch.countDown(); } } });Now I don’t think there should be anyway that the latch.countDown(); could be re-ordered to come before the makeMove().
This allows me to get the result of the Futures with a very small wait:
return future.get(1, TimeUnit.NANOSECONDS);
.But it still isn’t instant. My problem now being that the Future isn’t being set with the result in time. If you look at it from the other side, I’m not really hooking into the right part of the Future. I really need to trigger the countDown() after the future has been finished. The Callable interface doesn’t have any other methods I can hook into and my first search of the package leaves no leads.
At least I’m a little bit happier.
No comments:
Post a Comment