Closed gitboy16 closed 10 months ago
There is no lock however it's not thread safe to begin with.
No, none of the data structures in this repo are suitable for concurrent use. You want ConcurrentCollections.jl.
To help you work this out for yourself in the future, here are some hints:
Firstly, any kind of concurrent data structure will be significantly slower than a serial one, so unless a data structure says that it is lock-free then it usually won't be.
Secondly, lock-free algorithms avoid locks by using atomic operations (compare-and-swap, etc). So you can just check the source and see if any atomic operations are being used. Atomic operations in Julia use Threads.Atomic
or Base.@atomic
(manual), so we can just search the project for the string "atomic". Look, no hits. None of the data structures in this repo are lock-free.
If you don't trust github search, you could check one of the methods for the data structure, e.g. pop!
. It would need to have some kind of atomic operation if the data structure were lock free, and it doesn't.
Thank you both.
Hi, Is the implementation of CircularBuffer lock free? Thank you Regards.