Lock guards for Angelscript ContextPool
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
6146a2b22e
commit
fcc9988c3e
|
@ -18,19 +18,30 @@ class ContextPool {
|
|||
}
|
||||
};
|
||||
|
||||
std::mutex Lock;
|
||||
ArbUt::Dictionary<std::thread::id, CtxThreadedPoolStorage*> _pool;
|
||||
AngelScriptResolver* _resolver;
|
||||
AngelscriptUserdata* _userData;
|
||||
|
||||
CtxThreadedPoolStorage* CreateThreadPool(std::thread::id id) {
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
auto tryGet = _pool.TryGet(id);
|
||||
if (tryGet.has_value()) {
|
||||
return tryGet->get();
|
||||
}
|
||||
|
||||
auto p = new CtxThreadedPoolStorage();
|
||||
_pool.Insert(id, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
CtxThreadedPoolStorage* GetThreadPool() {
|
||||
auto id = std::this_thread::get_id();
|
||||
auto tryGet = _pool.TryGet(id);
|
||||
if (tryGet.has_value()) {
|
||||
return tryGet->get();
|
||||
}
|
||||
auto p = new CtxThreadedPoolStorage();
|
||||
_pool.Insert(id, p);
|
||||
return p;
|
||||
return CreateThreadPool(id);
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue