[Pogamut-list] Fast Traces in getSimpleRayCasting()
jacob.schrum
pogamut-forum at diana.ms.mff.cuni.cz
Wed May 18 05:04:17 CEST 2011
Re: Fast Traces in getSimpleRayCasting()
Author: jacob.schrum
Also, just to preemptively deal with possible trouble-shooting advice I might get:
I know that the listener works, because if I remove the BlockingQueue and simply have a
println() in the listener's notify() method, it prints out the value of the trace response.
The issue is that the listener is starving.
Also, despite the fact that the BlockingQueue is supposed to be a helpful abstraction that
makes things easier, I've also tried doing this using synchronized blocks, and I run into
the same problem:
{CODE()}
FastTraceResponse storedFTR = null;
final Object mutex = this;
IWorldEventListener fastTraceResponseHandler = new IWorldEventListener() {
@Override
public void notify(FastTraceResponse ftr) {
synchronized(mutex){
storedFTR = ftr;
mutex.notifyAll();
}
}
};
public Boolean quickTraceThroughWall(Location target) {
String id = "Quick";
body.getSimpleRayCasting().fastTrace(id, target);
Boolean result = null;
synchronized (mutex) {
while(storedFTR == null){
try {
mutex.wait(500);
} catch (InterruptedException ex) {
return null;
}
}
result = storedFTR.isResult();
storedFTR = null;
}
return result;
}
{CODE}
This code has the same problem: quickTraceThroughWall waits forever, and the listener
never executes.
--
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=761&post_reply=1#form>
More information about the Pogamut-list
mailing list