Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes mask deadlock for angle mask #2456

Closed
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 @@ -44,7 +44,7 @@ public static ChunkHolder newInstance() {
return POOL.poll();
}

private final Lock calledLock = new ReentrantLock();
private final ReentrantLock calledLock = new ReentrantLock();

private volatile IChunkGet chunkExisting; // The existing chunk (e.g. a clipboard, or the world, before changes)
private volatile IChunkSet chunkSet; // The blocks to be set to the chunkExisting
Expand All @@ -68,7 +68,6 @@ public void init(IBlockDelegate delegate) {

@Override
public synchronized void recycle() {
calledLock.lock();
delegate = NULL;
if (chunkSet != null) {
chunkSet.recycle();
Expand All @@ -77,7 +76,6 @@ public synchronized void recycle() {
chunkExisting = null;
extent = null;
POOL.offer(this);
calledLock.unlock();
}

public long initAge() {
Expand All @@ -92,10 +90,10 @@ public synchronized IBlockDelegate getDelegate() {
* If the chunk is currently being "called", this method will block until completed.
*/
private void checkAndWaitOnCalledLock() {
if (!calledLock.tryLock()) {
if (!calledLock.isLocked()) {
calledLock.lock();
calledLock.unlock();
}
calledLock.unlock();
}

@Override
Expand Down Expand Up @@ -1055,9 +1053,7 @@ public synchronized T call() {
try {
IChunkSet copy = chunkSet.createCopy();
chunkSet = null;
return this.call(copy, () -> {
// Do nothing
});
return this.call(copy, calledLock::unlock);
} catch (Throwable t) {
calledLock.unlock();
throw t;
Expand All @@ -1082,7 +1078,6 @@ public synchronized T call(IChunkSet set, Runnable finalize) {
} else {
finalizer = finalize;
}
calledLock.unlock();
return get.call(set, finalizer);
}
return null;
Expand Down
Loading