Improvements for Angelscript ContextPool

This commit is contained in:
Deukhoofd 2022-02-26 19:25:22 +01:00
parent d4a080714c
commit 6146a2b22e
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 6 additions and 4 deletions

View File

@ -24,11 +24,13 @@ class ContextPool {
CtxThreadedPoolStorage* GetThreadPool() {
auto id = std::this_thread::get_id();
if (!_pool.Has(id)) {
auto t = CtxThreadedPoolStorage();
_pool.Insert(id, new CtxThreadedPoolStorage());
auto tryGet = _pool.TryGet(id);
if (tryGet.has_value()) {
return tryGet->get();
}
return _pool[id];
auto p = new CtxThreadedPoolStorage();
_pool.Insert(id, p);
return p;
}
public: