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

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);
}
主站蜘蛛池模板: 京山县| 巴里| 贡觉县| 普定县| 马尔康县| 嘉鱼县| 阳谷县| 玉山县| 新民市| 汶川县| 濉溪县| 武清区| 弥渡县| 佛冈县| 隆化县| 大理市| 利辛县| 饶河县| 甘孜县| 沁源县| 张家港市| 炉霍县| 和硕县| 东乌珠穆沁旗| 运城市| 扬中市| 德保县| 迭部县| 吴桥县| 河东区| 玉田县| 沙田区| 洛宁县| 沅陵县| 衡阳市| 井陉县| 化德县| 镶黄旗| 甘谷县| 轮台县| 平果县|