AtomicChannels
AtomicChannels provides lock-free concurrent data structures for Julia:
AtomicChannel: fast multi-producer multi-consumer (MPMC) channel, implemented as a ring buffer with atomic operations to ensure thread safetyReusePool: object pool built on top ofAtomicChannel
Installation
using Pkg
Pkg.add("AtomicChannels")Quick Start
using AtomicChannels
chnl = AtomicChannel{Int}(2)
put!(chnl, 1)
put!(chnl, 2)
x = take!(chnl) # 1
y = trytake!(chnl) # 2
z = trytake!(chnl) # nothingpool = ReusePool(() -> Vector{Int}(undef, 16), 4, x -> fill!(x, 0))
buf = acquire!(pool)
buf[1] = 123
release!(pool, buf)