diff --git a/src/ScriptResolving/AngelScript/ContextPool.hpp b/src/ScriptResolving/AngelScript/ContextPool.hpp index c14601c..c06b6fa 100644 --- a/src/ScriptResolving/AngelScript/ContextPool.hpp +++ b/src/ScriptResolving/AngelScript/ContextPool.hpp @@ -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: