** Sleep for at least nMicro microseconds. Return the (approximate) number ** of microseconds slept for. */
| 728 | ** of microseconds slept for. |
| 729 | */ |
| 730 | static 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 |
nothing calls this directly
no test coverage detected