Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public Node lock(final int fromX, final int fromY, final int toX, final int toY)
final long[] areaAffected = new long[(toSectionX - fromSectionX + 1) * (toSectionY - fromSectionY + 1)];
int areaAffectedLen = 0;

final Node ret = new Node(this, areaAffected, currThread);
Node ret = new Node(this, areaAffected, currThread);

for (;;) {
Node park = null;
Expand Down Expand Up @@ -228,8 +228,9 @@ public Node lock(final int fromX, final int fromY, final int toX, final int toY)

areaAffectedLen = 0;

// since we inserted, we need to drain waiters
ret.notifier.notifyThreadsAndBlock();
// A contender may start waiting after this notification, so do not reuse the node.
ret.notifier.notifyThreads();
ret = new Node(this, areaAffected, currThread);
}

if (park == null) {
Expand All @@ -242,6 +243,7 @@ public Node lock(final int fromX, final int fromY, final int toX, final int toY)
}

// failed
park.notifier.waitUntilReady();
}
}

Expand Down