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

RandomAccessDataFile change Semaphore.acquire to Semaphore.acquireUni… #6683

Closed
wants to merge 1 commit into from
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 @@ -244,17 +244,11 @@ private class FilePool {
}

public RandomAccessFile acquire() throws IOException {
try {
this.available.acquire();
RandomAccessFile file = this.files.poll();
return (file == null
? new RandomAccessFile(RandomAccessDataFile.this.file, "r")
: file);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new IOException(ex);
}
this.available.acquireUninterruptibly();
RandomAccessFile file = this.files.poll();
return (file == null
? new RandomAccessFile(RandomAccessDataFile.this.file, "r")
: file);
}

public void release(RandomAccessFile file) {
Expand All @@ -263,22 +257,16 @@ public void release(RandomAccessFile file) {
}

public void close() throws IOException {
this.available.acquireUninterruptibly(this.size);
try {
this.available.acquire(this.size);
try {
RandomAccessFile file = this.files.poll();
while (file != null) {
file.close();
file = this.files.poll();
}
}
finally {
this.available.release(this.size);
RandomAccessFile file = this.files.poll();
while (file != null) {
file.close();
file = this.files.poll();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new IOException(ex);
finally {
this.available.release(this.size);
}
}

Expand Down