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

Method execAsync

fdbclient/include/fdbclient/AsyncTaskThread.h:80–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79 template <class F>
80 auto execAsync(const F& func, TaskPriority priority = TaskPriority::DefaultOnMainThread)
81 -> Future<decltype(func())> {
82 if (g_network->isSimulated()) {
83 return map(delayJittered(meanDelay), [func](Void _) { return func(); });
84 }
85 Promise<decltype(func())> promise;
86 addTask([promise, func, priority] {
87 try {
88 auto funcResult = func();
89 onMainThreadVoid([promise, funcResult] { promise.send(funcResult); }, priority);
90 } catch (Error& e) {
91 TraceEvent("ErrorExecutingAsyncTask").error(e);
92 onMainThreadVoid([promise, e] { promise.sendError(e); }, priority);
93 }
94 });
95 return promise.getFuture();
96 }
97};
98
99#endif

Callers 13

readMethod · 0.80
sizeMethod · 0.80
syncMethod · 0.80
sizeMethod · 0.80
writeFileMethod · 0.80
deleteContainerMethod · 0.80
blobExistsMethod · 0.80
createMethod · 0.80
existsMethod · 0.80
listFilesMethod · 0.80

Calls 10

mapFunction · 0.85
delayJitteredFunction · 0.85
addTaskFunction · 0.85
onMainThreadVoidFunction · 0.85
TraceEventClass · 0.85
isSimulatedMethod · 0.45
sendMethod · 0.45
errorMethod · 0.45
sendErrorMethod · 0.45
getFutureMethod · 0.45

Tested by

no test coverage detected