3 unstable releases
0.2.1 | Feb 5, 2025 |
---|---|
0.2.0 | Feb 5, 2025 |
0.1.0 | Feb 4, 2025 |
#342 in Concurrency
386 downloads per month
19KB
64 lines
Buffered Mutexes
Sometimes, multiple threads need to update a shared value so frequently that the
overhead of an atomic or a Mutex
becomes a bottleneck. If, however, only
the cumulative result of the update is important, and not any of the
intermediate values, a BufMutex
makes it possible to pass around multiple
cloneable SharedBufMutex
s containing a local value that can be updated
without synchronization, and that will be combined into the global value when
the SharedBufMutex
s are dropped. This pattern works particular well with
methods such as like rayon
's for_each_with
, map_with
, and so on.
Acknowledgments
This software has been partially supported by project SERICS (PE00000014) under the NRRP MUR program funded by the EU - NGEU. Views and opinions expressed are however those of the authors only and do not necessarily reflect those of the European Union or the Italian MUR. Neither the European Union nor the Italian MUR can be held responsible for them.