Skip to content

Commit

Permalink
Merge pull request #50 from JuliaData/jps/cmp-dref
Browse files Browse the repository at this point in the history
Add == and hash for DRef
  • Loading branch information
jpsamaroo authored May 14, 2021
2 parents abfb5de + 930dbcf commit 606c64b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "MemPool"
uuid = "f9f48841-c794-520a-933b-121f7ba6ed94"
license = "MIT"
desc = "a simple distributed data store"
version = "0.3.3"
version = "0.3.4"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
2 changes: 2 additions & 0 deletions src/datastore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mutable struct DRef
d
end
end
Base.:(==)(d1::DRef, d2::DRef) = (d1.owner == d2.owner) && (d1.id == d2.id)
Base.hash(d::DRef, h::UInt) = hash(d.id, hash(d.owner, h))

function Serialization.serialize(io::AbstractSerializer, d::DRef)
Serialization.serialize_cycle_header(io, d)
Expand Down
18 changes: 18 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@ end
end
=#

@testset "DRef equality" begin
d1 = poolset(1)
iob = IOBuffer()
serialize(iob, d1)
seek(iob, 0)
d2 = deserialize(iob)
@test d1 == d2
@test hash(d1) == hash(d2)

d = Dict{DRef, Int}()
d[d1] = 1
@test haskey(d, d1)
@test haskey(d, d2)
@test d[d2] == 1

pooldelete(d1)
end

@testset "set-get-delete" begin
r1 = poolset([1,2])
r2 = poolset(["abc","def"], 2)
Expand Down

4 comments on commit 606c64b

@jpsamaroo
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Changing package repo URL not allowed, please submit a pull request with the URL change to the target registry and retry.

@jpsamaroo
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/36735

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.4 -m "<description of version>" 606c64b913704ceb110590348662e63518f416a7
git push origin v0.3.4

Please sign in to comment.