- Mastering C++ Multithreading
- Maya Posch
- 75字
- 2021-07-15 17:34:06
Thread local storage
Qt offers TLS through its QThreadStorage class. Memory management of pointer type values is handled by it. Generally, one would set some kind of data structure as a TLS value to store more than one value per thread, as described, for example, in the QThreadStorage class documentation:
QThreadStorage<QCache<QString, SomeClass> > caches;
void cacheObject(const QString &key, SomeClass* object) {
caches.localData().insert(key, object);
}
void removeFromCache(const QString &key) {
if (!caches.hasLocalData()) { return; }
caches.localData().remove(key);
}
推薦閱讀
- Advanced Machine Learning with Python
- Developing Mobile Web ArcGIS Applications
- Three.js開(kāi)發(fā)指南:基于WebGL和HTML5在網(wǎng)頁(yè)上渲染3D圖形和動(dòng)畫(huà)(原書(shū)第3版)
- 算法基礎(chǔ):打開(kāi)程序設(shè)計(jì)之門(mén)
- Learning Linux Binary Analysis
- Reactive Programming With Java 9
- Mastering Google App Engine
- Symfony2 Essentials
- 微信小程序項(xiàng)目開(kāi)發(fā)實(shí)戰(zhàn)
- C# and .NET Core Test Driven Development
- Learning VMware vSphere
- 寫(xiě)給青少年的人工智能(Python版·微課視頻版)
- 小學(xué)生C++趣味編程從入門(mén)到精通
- BackTrack 5 Cookbook
- ASP.NET 3.5系統(tǒng)開(kāi)發(fā)精髓