MCPcopy Create free account
hub / github.com/Snapchat/Valdi / onComplete

Method onComplete

valdi_core/src/valdi_core/cpp/Utils/ResolvablePromise.cpp:58–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void ResolvablePromise::onComplete(const Ref<PromiseCallback>& callback) {
59 std::unique_lock<Mutex> lock(_mutex);
60 if (_canceled) {
61 return;
62 }
63
64 if (!_result.empty()) {
65 auto result = _result;
66 lock.unlock();
67
68 if (result) {
69 callback->onSuccess(result.value());
70 } else {
71 callback->onFailure(result.error());
72 }
73
74 return;
75 }
76
77 _callbacks.emplace_back(callback);
78}
79
80bool ResolvablePromise::isCancelable() const {
81 std::lock_guard<Mutex> lock(_mutex);

Callers

nothing calls this directly

Calls 6

valueMethod · 0.65
errorMethod · 0.65
emptyMethod · 0.45
unlockMethod · 0.45
onSuccessMethod · 0.45
onFailureMethod · 0.45

Tested by

no test coverage detected