* Semantically blocks the current fiber until the clock time is equal to or * greater than the specified duration. Once the clock time is adjusted to * on or after the duration, the fiber will automatically be resumed.
(durationInput: Duration.DurationInput)
| 191 | * on or after the duration, the fiber will automatically be resumed. |
| 192 | */ |
| 193 | sleep(durationInput: Duration.DurationInput): Effect.Effect<void> { |
| 194 | const duration = Duration.decode(durationInput) |
| 195 | return core.flatMap(core.deferredMake<void>(), (deferred) => |
| 196 | pipe( |
| 197 | ref.modify(this.clockState, (data) => { |
| 198 | const end = data.instant + Duration.toMillis(duration) |
| 199 | if (end > data.instant) { |
| 200 | return [ |
| 201 | true, |
| 202 | makeData(data.instant, pipe(data.sleeps, Chunk.prepend([end, deferred] as const))) |
| 203 | ] as const |
| 204 | } |
| 205 | return [false, data] as const |
| 206 | }), |
| 207 | core.flatMap((shouldAwait) => |
| 208 | shouldAwait ? |
| 209 | pipe(this.warningStart(), core.zipRight(core.deferredAwait(deferred))) : |
| 210 | pipe(core.deferredSucceed(deferred, void 0), core.asVoid) |
| 211 | ) |
| 212 | )) |
| 213 | } |
| 214 | /** |
| 215 | * Returns a list of the times at which all queued effects are scheduled to |
| 216 | * resume. |
nothing calls this directly
no test coverage detected