SimpleRateLimiter

Simple class to rate limit IO.

Constructors

Link copied to clipboard
constructor(mbPerSec: Double)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override var mBPerSec: Double

Sets an updated MB per second rate limit. A subclass is allowed to perform dynamic updates of the rate limit during use.

Link copied to clipboard
open override var minPauseCheckBytes: Long

How many bytes caller should add up itself before invoking .pause. NOTE: The value returned by this method may change over time and is not guaranteed to be constant throughout the lifetime of the RateLimiter. Users are advised to refresh their local values with calls to this method to ensure consistency.

Functions

Link copied to clipboard
open suspend override fun pause(bytes: Long): Long

Pauses, if necessary, to keep the instantaneous IO rate at or below the target. Be sure to only call this method when bytes >.getMinPauseCheckBytes, otherwise it will pause way too long!