Skip to content

Commit

Permalink
Merge pull request #92 from JuliaData/jps/no-unsafeatomics
Browse files Browse the repository at this point in the history
Remove UnsafeAtomics dependency
  • Loading branch information
jpsamaroo authored Dec 5, 2024
2 parents 3d77bff + 1d4f78c commit 41e6dd6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f"

[compat]
ConcurrentCollections = "0.1"
DataStructures = "0.18"
DistributedNext = "1"
Preferences = "1"
ScopedValues = "1"
UnsafeAtomics = "0.2"
julia = "1.9"

[extras]
Expand Down
6 changes: 2 additions & 4 deletions src/read_write_lock.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Adapted from ConcurrentUtils/src/read_write_lock.jl

import UnsafeAtomics

abstract type AbstractReadWriteLock <: Base.AbstractLock end

const NOTLOCKED = UInt64(0)
Expand Down Expand Up @@ -67,7 +65,7 @@ function lock_read(rwlock::ReadWriteLock)
pointer_from_objref(rwlock) + OFFSET_NREADERS_AND_WRITELOCK,
)
GC.@preserve rwlock begin
_, n = UnsafeAtomics.modify!(ptr, +, NREADERS_INC, UnsafeAtomics.acq_rel)
_, n = Core.Intrinsics.atomic_pointermodify(ptr, +, NREADERS_INC, :acquire_release)
end
# n = @atomic :acquire_release rwlock.nreaders_and_writelock += NREADERS_INC

Expand All @@ -93,7 +91,7 @@ function unlock_read(rwlock::ReadWriteLock)
pointer_from_objref(rwlock) + OFFSET_NREADERS_AND_WRITELOCK,
)
GC.@preserve rwlock begin
_, n = UnsafeAtomics.modify!(ptr, -, NREADERS_INC, UnsafeAtomics.acq_rel)
_, n = Core.Intrinsics.atomic_pointermodify(ptr, -, NREADERS_INC, :acquire_release)
end
# n = @atomic :acquire_release rwlock.nreaders_and_writelock -= NREADERS_INC

Expand Down

0 comments on commit 41e6dd6

Please sign in to comment.