forked from JuliaIO/HDF5.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement try_close_finalizer, do not wait for liblock, fix JuliaIO#1048
- Loading branch information
Showing
5 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const liblock = ReentrantLock() | ||
|
||
# Try to acquire the lock (test-test-set) and close if successful | ||
# Otherwise, defer finalization | ||
# https://github.com/JuliaIO/HDF5.jl/issues/1048 | ||
function try_close_finalizer(x) | ||
if !islocked(liblock) && | ||
trylock(liblock) do | ||
close(x) | ||
true | ||
end | ||
else | ||
finalizer(try_close_finalizer, x) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters