-
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.
- Loading branch information
1 parent
e0bf82d
commit 2ee66f5
Showing
12 changed files
with
103 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,15 @@ uuid = "c7313018-426c-4109-b567-6f433e2229c2" | |
authors = ["josePereiro <[email protected]> and contributors"] | ||
version = "1.0.0-DEV" | ||
|
||
[compat] | ||
julia = "1.6" | ||
|
||
[deps] | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | ||
SimpleLockFiles = "0c975e61-21d9-4454-8de5-ff08fd2c478f" | ||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | ||
|
||
[compat] | ||
julia = "1.6" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
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,25 @@ | ||
# this just requere to implement a _getlock | ||
|
||
function _lock(f::Function, B::Bloberia; kwargs...) | ||
lk = _getlock(B) | ||
isnothing(lk) && return f() # ignore locking | ||
lock(f, lk, kwargs...) | ||
end | ||
function _lock(B::Bloberia; kwargs...) | ||
lk = _getlock(B) | ||
isnothing(lk) && return # ignore locking | ||
lock(lk, kwargs...) | ||
return B | ||
end | ||
|
||
function _islocked(B::Bloberia) | ||
lk = _getlock(B) | ||
isnothing(lk) && return false | ||
return islocked(lk) | ||
end | ||
|
||
function _unlock(B::Bloberia; force = false) | ||
lk = _getlock(B) | ||
isnothing(lk) && return # ignore | ||
return unlock(lk; force) | ||
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
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,14 @@ | ||
_pidfile(bb::BlobBatches) = joinpath(batchpath(bb), "bb.pidfile") | ||
_getlock(bb::BlobBatches) = get!(() -> SimpleLockFile(_pidfile(bb)), bb.temp, "_lock") | ||
_setlock!(bb::BlobBatches, lk) = setindex!(bb["temp"], lk, "_lock") | ||
|
||
import Base.lock | ||
Base.lock(f::Function, bb::BlobBatches; kwargs...) = _lock(f, bb; kwargs...) | ||
Base.lock(bb::BlobBatches; kwargs...) = _lock(bb; kwargs...) | ||
|
||
import Base.islocked | ||
Base.islocked(bb::BlobBatches) = _islocked(bb) | ||
|
||
import Base.unlock | ||
Base.unlock(bb::BlobBatches; force = false) = _unlock(bb; force) | ||
|
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
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,14 @@ | ||
_pidfile(B::Bloberia) = joinpath(B.root, "B.pidfile") | ||
_getlock(B::Bloberia) = get!(() -> SimpleLockFile(_pidfile(B)), B.temp, "_lock") | ||
_setlock!(B::Bloberia, lk) = setindex!(B["temp"], lk, "_lock") | ||
|
||
import Base.lock | ||
Base.lock(f::Function, B::Bloberia; kwargs...) = _lock(f, B; kwargs...) | ||
Base.lock(B::Bloberia; kwargs...) = _lock(B; kwargs...) | ||
|
||
import Base.islocked | ||
Base.islocked(B::Bloberia) = _islocked(B) | ||
|
||
import Base.unlock | ||
Base.unlock(B::Bloberia; force = false) = _unlock(B; force) | ||
|
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 |
---|---|---|
|
@@ -2,5 +2,6 @@ using Bloberias | |
using Test | ||
|
||
@testset "Bloberias.jl" begin | ||
# Write your tests here. | ||
B = Bloberia() | ||
@test true | ||
end |