ThreadSafeDicts.jl
A thread-safe Dict type for Julia programming

Struct and Constructors
ThreadSafeDict
struct ThreadSafeDict{K,V} <: AbstractDict{K,V}
dlock::ReentrantLock
d::Dict{K,V}
ThreadSafeDict{K,V}() where {K,V} = new(ReentrantLock(), Dict{K,V}())
ThreadSafeDict{K,V}(d::Dict{K,V}) where {K,V} =
new(ReentrantLock(), copy(d))
ThreadSafeDict{K,V}(itr) where {K,V} =
new(ReentrantLock(), Dict{K,V}(itr))
end
ThreadSafeDict()
ThreadSafeDict(d::Dict{K,V}) where {K,V}
ThreadSafeDict(itr)Struct and constructors for ThreadSafeDict. There is one private ReentrantLock per Dict struct. All functions lock this lock, pass arguments to the d member Dict, unlock the ReentrantLock, and then return what is returned by the Dict.
Installation
using Pkg
Pkg.add("ThreadSafeDicts")Functions Reference
ThreadSafeDicts.ThreadSafeDictBase.delete!Base.empty!Base.getBase.getBase.get!Base.get!Base.getindexBase.haskeyBase.iterateBase.iterateBase.lengthBase.pop!Base.printBase.setindex!
ThreadSafeDicts.ThreadSafeDict — Type
ThreadSafeDict(pairs::Vector{Pair{K,V}})Struct and constructor for ThreadSafeDict. There is one ReentrantLock per Dict struct. All functions lock this lock, pass arguments to the d member Dict, unlock the lock, and then return what is returned by the Dict.
Base.delete! — Method
delete!(dic::ThreadSafeDict, k)delete key k and its value from the dict
Base.empty! — Method
empty!(dic::ThreadSafeDict)Remove all keys and values from the Dict
Base.getindex — Method
getindex(dic::ThreadSafeDict, k)Get the value at key index k.
Base.haskey — Method
haskey(dic::ThreadSafeDict, k)Return true if key k is in the dict, else return false.
Base.iterate — Method
iterate(dic::ThreadSafeDict, i)Iterate through the Dict returning its key-value pairs.
Base.iterate — Method
iterate(dic::ThreadSafeDict)Iterate through the Dict returning its key-value pairs.
Base.length — Method
length(dic::ThreadSafeDict)Return the length of the Dict, considered as a vector of key-value pairs
Base.print — Method
print(io::IO, dic::ThreadSafeDict)Print the ThreadSafeDict, including the state of its lock and contents of the undelying Dict.
Base.setindex! — Method
setindex!(dic::ThreadSafeDict, k, v)Set the value at key index k to v.