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

Method scheduleFlush

valdi/src/valdi/android/AndroidDispatchQueue.cpp:61–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void AndroidDispatchQueue::scheduleFlush(std::chrono::steady_clock::duration delay) {
62 // TODO(simon): We could avoid scheduling a flush for every tasks.
63
64 auto finish = std::chrono::steady_clock::now() + delay;
65 auto* self = Valdi::unsafeRetain(this);
66 auto* cb = new Valdi::DispatchFunction([self, finish]() {
67 auto remaining = finish - std::chrono::steady_clock::now();
68 if (remaining.count() > 0) {
69 self->scheduleFlush(remaining);
70 } else {
71 self->flush();
72 }
73 Valdi::unsafeRelease(self);
74 });
75
76 int64_t delayMs = std::chrono::duration_cast<std::chrono::milliseconds>(delay).count();
77 if (delayMs == 0) {
78 _dispatcher->dispatch(cb, false);
79 } else {
80 _dispatcher->dispatchAfter(delayMs, cb);
81 }
82}
83
84void AndroidDispatchQueue::flush() {
85 if (!_mainThreadId.has_value()) {

Callers

nothing calls this directly

Calls 7

flushMethod · 0.95
unsafeRetainFunction · 0.85
unsafeReleaseFunction · 0.85
countMethod · 0.80
dispatchAfterMethod · 0.80
nowFunction · 0.50
dispatchMethod · 0.45

Tested by

no test coverage detected