This commit is contained in:
parent
dd415c957a
commit
1221fc85e8
1 changed files with 25 additions and 27 deletions
|
@ -75,8 +75,7 @@ object MonotonicProvider:
|
|||
final class SystemProvider[F[_]: Sync] extends MonotonicProvider[F]:
|
||||
override def monotonic(): F[Long] = Sync[F].delay(System.nanoTime())
|
||||
|
||||
/**
|
||||
* Manual implementation of the [[MonotonicProvider]] that allows the caller
|
||||
/** Manual implementation of the [[MonotonicProvider]] that allows the caller
|
||||
* to directly increment/set a tick count, where each tick corresponds to one
|
||||
* nanosecond of elapsed time.
|
||||
*
|
||||
|
@ -90,26 +89,25 @@ object MonotonicProvider:
|
|||
final class ManualTickProvider[F[_]: Sync] private (
|
||||
ticks: Ref[F, Long]
|
||||
) extends MonotonicProvider[F]:
|
||||
/**
|
||||
* @return The current tick count.
|
||||
/** @return
|
||||
* The current tick count.
|
||||
*/
|
||||
override def monotonic(): F[Long] = ticks.get
|
||||
|
||||
/**
|
||||
* Increment the tick count by 1.
|
||||
/** Increment the tick count by 1.
|
||||
*/
|
||||
def tick(): F[Unit] = ticks.update(_ + 1)
|
||||
|
||||
/**
|
||||
* Set the tick count to a specific value.
|
||||
/** Set the tick count to a specific value.
|
||||
*
|
||||
* @param newTickCount The new tick count value.
|
||||
* @return Side-effect.
|
||||
* @param newTickCount
|
||||
* The new tick count value.
|
||||
* @return
|
||||
* Side-effect.
|
||||
*/
|
||||
def set(newTickCount: Long): F[Unit] = ticks.set(newTickCount)
|
||||
|
||||
/**
|
||||
* Reset the tick count to 0.
|
||||
/** Reset the tick count to 0.
|
||||
*/
|
||||
def reset(): F[Unit] = ticks.set(0)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue