TrafficMonitorLock

A traffic monitor lock, responsible for conditionally synchronizing. We use this implementation to skip the synchronization overhead most of the time. The only time we do use synchronization is when net.rsprot.protocol.metrics.NetworkTrafficMonitor.resetTransient function is called, during which we shortly lock the modifications down in order to ensure consistency in the measurements.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
inline fun transfer(block: () -> Unit)

Synchronizes around a newly created lock to temporarily prevent any modifications to a net.rsprot.protocol.metrics.NetworkTrafficMonitor. While the block executes, the use function will not be able to execute.

Link copied to clipboard
inline fun <R> use(block: () -> R): R

Conditionally synchronizes around the lock object, only if the lock object is not null. Majority of the time, the lock will be null, which means no synchronization takes place.