https://github.com/kardbord/concurrency
Sharded, thread-safe implementations of STL containers.
https://github.com/kardbord/concurrency
concurrency cpp cpp17 thread-safe thread-safety
Last synced: 3 months ago
JSON representation
Sharded, thread-safe implementations of STL containers.
- Host: GitHub
- URL: https://github.com/kardbord/concurrency
- Owner: Kardbord
- License: mit
- Created: 2022-06-23T06:53:50.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-19T06:05:56.000Z (almost 3 years ago)
- Last Synced: 2025-01-24T22:12:22.312Z (5 months ago)
- Topics: concurrency, cpp, cpp17, thread-safe, thread-safety
- Language: C++
- Homepage:
- Size: 136 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Concurrency
[](https://github.com/TannerKvarfordt/Concurrency/actions/workflows/cmake.yml)
This project provides thread-safe wrappers around C++ standard library containers. Most standard library functionality is preserved, though
some exceptions have to be made to remove footguns in the context of concurrent access. Notably, iterator access is not supported for most
wrappers.## Installation
**NOTE** - This library requires C++17.
This is a header-only library. There are several ways to make use of the provided headers.
- [`./tools/install.sh`](./tools/install.sh). Invoke this script, optionally providing an installation directory with the `-p` option.
- Alternatively, simply copy the contents of `include/` to your system.Either way, you'll have to make sure that the location of the headers is known your build environment. At that point, you
can include the headers as you would any others.## Container Wrappers
### [`std::unordered_map`](https://en.cppreference.com/w/cpp/container/unordered_map)
[`::concurrency::UnorderedMap`](include/concurrency/UnorderedMap.hpp) is a simple wrapper around `std::unordered_map` which
allows thread-safe access via an internal [`std::shared_mutex`](https://en.cppreference.com/w/cpp/thread/shared_mutex).[`::concurrency::ShardedUnorderedMap`](include/concurrency/ShardedUnorderedMap.hpp) provides the same interfaces as `::concurrency::UnorderedMap`, but employs sharding in an effort to improve
write-access performance. By splitting the underlying data into multiple `::concurrency::UnorderedMap`s, multiple
threads may obtain write access at once, provided the respective keys they are accessing are stored in different
shards. See the [map_benchmark example](examples/map_benchmark/) for performance metrics.