官术网_书友最值得收藏!

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);
}
主站蜘蛛池模板: 天峻县| 枣阳市| 北京市| 南丰县| 攀枝花市| 灌南县| 襄垣县| 柘城县| 平顶山市| 邻水| 织金县| 景洪市| 定陶县| 申扎县| 佛教| 铜川市| 萝北县| 尚义县| 志丹县| 瑞安市| 清水河县| 新巴尔虎右旗| 绥中县| 文山县| 怀柔区| 红安县| 日喀则市| 满城县| 北川| 元氏县| 瓦房店市| 庆安县| 沂南县| 迁西县| 宁化县| 西乡县| 长岭县| 浑源县| 颍上县| 洛阳市| 乡宁县|