Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ authors = ["Takafumi Arakaki <[email protected]> and contributors"]
version = "0.1.0-DEV"

[deps]
ConcurrentUtils = "3df5f688-6c4c-4767-8685-17f5ad261477"
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f"

[compat]
ConcurrentUtils = "0.1"
UnsafeAtomics = "0.1"
julia = "1.7"
7 changes: 3 additions & 4 deletions src/LeftRight.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ baremodule LeftRight

export guarding_read, guarding

# TODO: Move them to ConcurrentUtils
function guarding_read end
function guarding end

module Internal

using UnsafeAtomics: UnsafeAtomics, acq_rel, seq_cst
using ConcurrentUtils: ConcurrentUtils, guarding_read, guarding, spinloop

using ..LeftRight: LeftRight

Expand All @@ -17,6 +14,8 @@ include("core.jl")

end # module Internal

const guarding = Internal.guarding
const guarding_read = Internal.guarding_read
const Guard = Internal.Guard
# const SimpleGuard = Internal.SimpleGuard

Expand Down
4 changes: 2 additions & 2 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function release_read(::GenericGuard, token)
return
end

function LeftRight.guarding_read(f, g::GenericGuard)
function ConcurrentUtils.guarding_read(f, g::GenericGuard)
token, data = acquire_read(g)
try
return f(data)
Expand All @@ -189,7 +189,7 @@ function LeftRight.guarding_read(f, g::GenericGuard)
end
end

function LeftRight.guarding(f!, g::GenericGuard)
function ConcurrentUtils.guarding(f!, g::GenericGuard)
lock(g.lock)
try
# No need to use `:acquire` since the lock already has ordered the access:
Expand Down
5 changes: 0 additions & 5 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ end
const var"@const" = var"@_const"

pad7() = ntuple(_ -> 0, Val(7))

function spinloop()
GC.safepoint()
ccall(:jl_cpu_pause, Cvoid, ())
end