diff --git a/Source/Async/WorkItem.cpp b/Source/Async/WorkItem.cpp index bbfee961..d2cc5c4e 100644 --- a/Source/Async/WorkItem.cpp +++ b/Source/Async/WorkItem.cpp @@ -42,8 +42,16 @@ namespace Aurora::Async status = true; } - dependency->waiters_.push_back(shared_from_this()); - this->waitOn_.push_back(workItem); + if (!AuTryInsert(dependency->waiters_, AuSharedFromThis())) + { + return false; + } + + if (!AuTryInsert(this->waitOn_, workItem)) + { + AuTryRemove(dependency->waiters_, AuSharedFromThis()); + return false; + } } if (status)