| 217 | } |
| 218 | |
| 219 | void Context::markUpdateCompleted(ContextUpdateId updateId, std::unique_lock<Mutex>& guard) { |
| 220 | std::vector<Ref<ValueFunction>> updateCompletedCallbacks; |
| 221 | |
| 222 | if (!guard.owns_lock()) { |
| 223 | guard.lock(); |
| 224 | } |
| 225 | |
| 226 | auto it = _pendingUpdates.find(updateId); |
| 227 | if (it != _pendingUpdates.end()) { |
| 228 | _pendingUpdates.erase(it); |
| 229 | if (_pendingUpdates.empty()) { |
| 230 | std::swap(updateCompletedCallbacks, _updateCompletedCallbacks); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | guard.unlock(); |
| 235 | |
| 236 | callUpdateCompletedCallbacks(updateCompletedCallbacks); |
| 237 | } |
| 238 | |
| 239 | ContextUpdateId Context::lockFreeEnqueueUpdate() { |
| 240 | if (_destroyed) { |