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

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);
}
主站蜘蛛池模板: 沛县| 大名县| 深泽县| 西盟| 霍邱县| 澄城县| 吐鲁番市| 红河县| 建湖县| 蓬安县| 土默特左旗| 尚义县| 昌图县| 盐城市| 明光市| 汝城县| 绿春县| 天等县| 濮阳市| 宜良县| 思茅市| 万荣县| 搜索| 云林县| 同心县| 白银市| 化隆| 大化| 大化| 灵山县| 揭西县| 合肥市| 曲松县| 通许县| 兴和县| 清远市| 长沙市| 资溪县| 关岭| 静宁县| 涟水县|