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

Method sync

valdi_core/src/valdi_core/cpp/Threading/ThreadedDispatchQueue.cpp:52–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void ThreadedDispatchQueue::sync(const Valdi::DispatchFunction& function) {
53 if (_disableSyncCallsInCallingThread) {
54 std::promise<void> promise;
55 auto future = promise.get_future();
56
57 async([&function, &promise, this]() {
58 _runningSync = true;
59 function();
60
61 promise.set_value();
62 _runningSync = false;
63 });
64
65 future.get();
66 return;
67 }
68
69 _taskQueue->barrier([&]() {
70 auto* previousCurrent = current;
71 current = this;
72 _runningSync = true;
73 function();
74 current = previousCurrent;
75 _runningSync = false;
76 });
77}
78
79void ThreadedDispatchQueue::async(Valdi::DispatchFunction function) {
80 auto task = _taskQueue->enqueue(std::move(function));

Callers

nothing calls this directly

Calls 3

set_valueMethod · 0.80
barrierMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected