-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
sleep
method that takes scala.concurrent.duration, with docum…
…entation (#51)
- Loading branch information
1 parent
aad1146
commit 9723588
Showing
1 changed file
with
14 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
package gears.async | ||
|
||
import scala.concurrent.duration.FiniteDuration | ||
|
||
trait AsyncOperations: | ||
/** Suspends the current [[Async]] context for at least [[millis]] milliseconds. */ | ||
def sleep(millis: Long)(using Async): Unit | ||
|
||
object AsyncOperations: | ||
/** Suspends the current [[Async]] context for at least [[millis]] milliseconds. | ||
* @param millis | ||
* The duration to suspend. Must be a positive integer. | ||
*/ | ||
inline def sleep(millis: Long)(using AsyncOperations, Async): Unit = | ||
summon[AsyncOperations].sleep(millis) | ||
|
||
/** Suspends the current [[Async]] context for at least [[millis]] milliseconds. | ||
* @param duration | ||
* The duration to suspend. Must be positive. | ||
*/ | ||
inline def sleep(duration: FiniteDuration)(using AsyncOperations, Async): Unit = | ||
sleep(duration.toMillis) |