MCPcopy Create free account
hub / github.com/apple/foundationdb / onMainThread

Function onMainThread

flow/include/flow/ThreadHelper.actor.h:809–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

807// TODO: Add SFINAE overloads for functors returning void or a non-Future type.
808template <class F>
809ThreadFuture<decltype(std::declval<F>()().getValue())> onMainThread(F f) {
810 Promise<Void> signal;
811 auto returnValue = new ThreadSingleAssignmentVar<decltype(std::declval<F>()().getValue())>();
812 returnValue->addref(); // For the ThreadFuture we return
813 // TODO: Is this cancellation logic actually needed?
814 Future<Void> cancelFuture = internal_thread_helper::doOnMainThread<decltype(std::declval<F>()().getValue()), F>(
815 signal.getFuture(), f, returnValue);
816 returnValue->setCancel(std::move(cancelFuture));
817 g_network->onMainThread(std::move(signal), TaskPriority::DefaultOnMainThread);
818 return ThreadFuture<decltype(std::declval<F>()().getValue())>(returnValue);
819}
820
821template <class V>
822class ThreadSafeAsyncVar : NonCopyable, public ThreadSafeReferenceCounted<ThreadSafeAsyncVar<V>> {

Callers 5

bench_callbackFunction · 0.50
bench_net2Function · 0.50
bench_streamFunction · 0.50
bench_ionet2Function · 0.50

Calls 6

moveFunction · 0.85
setCancelMethod · 0.80
getValueMethod · 0.45
addrefMethod · 0.45
getFutureMethod · 0.45
onMainThreadMethod · 0.45

Tested by

no test coverage detected