Comments (3)
Hello @laurentcau,
What you describes relates to "transaction" thread-safety rather than object thread-safety. Indeed, a reference/pointer returned by Get
/TryGet
methods may be invalidated by calls to Put
/Remove
. But it is up to a caller to provide a safety of a cache container in a multithreading environment. Or a method might be introduced that would return a shared pointer to a data to avoid early resource invalidation.
I would be more than happy to merge such a change if you see a value for doing so. 😄
from caches.
from caches.
Missed a response there. 🤦
If you have to manage thread-safety on caller side, this mutex is useless.
No, it is not asPut
/Get
operation is not atomic, thus we cannot have thread-safety without locking underlying containers.
Regarding what you described - it is fully application specific. If you have separate threads - one for getting and processing data in cache and another one for putting data into a cache, you are responsible for locking producer-consumer to avoid freed data manipulation.
Since it is quite old thread, I'll close it, but feel free to re-open it, if you have an example that shows why we need to update the existing interface to get rid of references.
from caches.
Related Issues (15)
- operation_guard not locking HOT 3
- Update Get method to return std::optional HOT 2
- using as cmake HOT 1
- small edit in the readme example HOT 1
- Uncomplicated multithreaded design? HOT 2
- FIFO cache policy Key Removal mismatches actual removed key HOT 2
- Pass map as template param to replace unorder_map HOT 4
- cache_policy.hpp raises warning when compiled with -Wunused-parameter HOT 1
- It works for iOS and Android? HOT 2
- 是否支持时间过期? HOT 2
- 你好,请问是线程安全的吗
- `std::unordered_set` does not have a function named `crbegin` HOT 2
- overload the Get function when the key is not in the cache HOT 2
- change the permission for Erase() to public HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caches.