static final int WAIT_TIME = 60000;
- public static final boolean PRINT = false;
+ public static final boolean PRINT = BarrierTracing.BOOKKEEPING && true;
final AsyncBarrierImpl caller;
void inc(Object id, String info) {
if(PRINT) {
- System.err.println("inc barrier[" + get() + "] " + this);
+ LOGGER.warn("inc barrier[" + get() + "] " + this);
StackTraceElement[] elems = new Exception().getStackTrace();
- for(int i=0;i<4;i++) System.err.println(elems[i]);
+ for(int i=0;i<4;i++) LOGGER.warn("{}", elems[i]);
}
if (incrementAndGet() == 1) {
public void dec() {
if(PRINT) {
- System.err.println("dec barrier[" + get() + "] " + this);
+ LOGGER.warn("dec barrier[" + get() + "] " + this);
StackTraceElement[] elems = new Exception().getStackTrace();
- for(int i=0;i<3;i++) System.err.println(elems[i]);
+ for(int i=0;i<3;i++) LOGGER.warn("{}", elems[i]);
}
int count = decrementAndGet();
public static String report(AsyncBarrierImpl barrier) {
CacheEntry<?> e = BarrierTracing.entryMap.get(barrier);
if(e != null) return e.toString();
- else return "Barrier@" + System.identityHashCode(barrier);
+ else return "[" + barrier.get() + " requests]: Barrier@" + System.identityHashCode(barrier);
}
public static void printReverse(AsyncBarrierImpl barrier, int indent) {
return;
for (int i = 0; i < indent; i++)
System.err.print(" ");
- System.err.println("[" + barrier.get() + " requests]: " + report(barrier));
+ System.err.println(report(barrier));
Collection<AsyncBarrierImpl> children = BarrierTracing.reverseLookup.get(barrier);
if (children != null) {
LOGGER.warn("AsyncBarrierImpl.waitBarrier("
+ request
+ ") is taking long to execute, so far "
- + (waitCount / 1000) + " s.");
+ + (waitCount / 1000) + " s. this.get() = " + get());
if (BarrierTracing.BOOKKEEPING) {
synchronized (BarrierTracing.reverseLookup) {
boolean routeLineDoesNotIntersectTerminal;
double linePosition = line.position;
if(line.isHorizontal) {
+ if (linePosition == y) {
+ // direct route to terminal
+ line.addPoint(this);
+ return;
+ }
lineDir = linePosition < y ? 3 : 1;
routeLineDoesNotIntersectTerminal = linePosition <= minY || linePosition >= maxY
|| boundingBoxesIntersect /* we ignore intersection in this case */;
}
else {
+ if (linePosition == x) {
+ // direct route to terminal
+ line.addPoint(this);
+ return;
+ }
lineDir = linePosition < x ? 2 : 0;
routeLineDoesNotIntersectTerminal = linePosition <= minX || linePosition >= maxX
|| boundingBoxesIntersect /* we ignore intersection in this case */;
}
// We can route the connection directly to the right direction
- if(routeLineDoesNotIntersectTerminal &&
+ if((routeLineDoesNotIntersectTerminal ||
+ (line.isHorizontal && (x == minX || x == maxX)) || // already on the top/bottom edge
+ (!line.isHorizontal && (y == minY || y == maxY)) // already on the left/right edge
+ ) &&
Directions.isAllowed(allowedDirections, lineDir)) {
RouteLine line0 = createLine0(lineDir);
new RouteLink(line0, line);