#lock-free #atomic #bag #safe-wrapper

no-std orx-pinned-concurrent-col

A core data structure with a focus to enable high performance, possibly lock-free, concurrent collections using a PinnedVec as the underlying storage

17 stable releases

2.8.0 Sep 20, 2024
2.7.0 Sep 6, 2024
2.6.0 Aug 28, 2024
2.2.0 Jul 25, 2024
1.1.0 Apr 12, 2024

#1099 in Concurrency

Download history 453/week @ 2024-07-19 713/week @ 2024-07-26 799/week @ 2024-08-02 360/week @ 2024-08-09 283/week @ 2024-08-16 544/week @ 2024-08-23 524/week @ 2024-08-30 976/week @ 2024-09-06 688/week @ 2024-09-13 1060/week @ 2024-09-20 796/week @ 2024-09-27 666/week @ 2024-10-04 518/week @ 2024-10-11 581/week @ 2024-10-18 485/week @ 2024-10-25 705/week @ 2024-11-01

2,381 downloads per month
Used in 5 crates

MIT license

52KB
569 lines

orx-pinned-concurrent-col

orx-pinned-concurrent-col crate orx-pinned-concurrent-col documentation

A core data structure with a focus to enable high performance, possibly lock-free, concurrent collections using a PinnedVec as the underlying storage.

Pinned vectors grow while keeping the already pushed elements pinned to their memory locations. This allows the following concurrency model.

  • Writing to the collection does not block. Multiple writes can happen concurrently.
    • However, PinnedConcurrentCol itself does not provide guarantees for race-free writing; and hence, the write methods are marked unsafe.
    • It is the responsibility of the wrapper to make sure that multiple writes or reading during write to the same position do not happen concurrently.
  • Only one growth (capacity expansion) can happen at a given time.
    • If the underlying collection reaches its capacity and needs to grow, one and only one thread takes the responsibility to expand the vector.
  • Growth does not block.
    • Writes to positions which are already within capacity are not blocked by the growth.
    • Writes to to-be-allocated positions wait only for the allocation to be completed; not any other task of the thread responsible for expansion.

As clear from the properties, pinned concurrent collection aims to achieve high performance. It exposes the useful methods that can be used differently for different requirements and marks the methods which can lead to race conditions as unsafe by stating the underlying reasons. This enables building safe wrappers such as ConcurrentBag, ConcurrentOrderedBag or ConcurrentVec.

Contributing

Contributions are welcome! If you notice an error, have a question or think something could be improved, please open an issue or create a PR.

License

This library is licensed under MIT license. See LICENSE for details.

Dependencies

~475KB