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

Function asyncSleep

fdbserver/VFSAsync.cpp:730–748  ·  view source on GitHub ↗

** Sleep for at least nMicro microseconds. Return the (approximate) number ** of microseconds slept for. */

Source from the content-addressed store, hash-verified

728** of microseconds slept for.
729*/
730static int asyncSleep(sqlite3_vfs* pVfs, int microseconds) {
731 try {
732 Future<Void> simCancel = Never();
733 if (g_network->isSimulated())
734 simCancel = success(g_simulator.getCurrentProcess()->shutdownSignal.getFuture());
735 if (simCancel.isReady()) {
736 waitFor(delay(FLOW_KNOBS->MAX_BUGGIFIED_DELAY));
737 return 0;
738 }
739 waitFor(g_network->delay(microseconds * 1e-6, TaskPriority::DefaultDelay) || simCancel);
740 return microseconds;
741 } catch (Error& e) {
742 if (e.isInjectedFault()) {
743 VFSAsyncFile::setInjectedError(SQLITE_ERROR);
744 }
745 TraceEvent(SevError, "VFSAsyncSleepError").errorUnsuppressed(e);
746 return 0;
747 }
748}
749
750/*
751** Find the current time (in Universal Coordinated Time). Write into *piNow

Callers

nothing calls this directly

Calls 10

waitForFunction · 0.85
delayFunction · 0.85
TraceEventClass · 0.85
getCurrentProcessMethod · 0.80
isInjectedFaultMethod · 0.80
NeverClass · 0.50
isSimulatedMethod · 0.45
getFutureMethod · 0.45
isReadyMethod · 0.45
delayMethod · 0.45

Tested by

no test coverage detected