criticalSection

inline fun <T> AtomicBoolean.criticalSection(block: () -> T): T

Executes block while this AtomicBoolean is set to true, resetting it to false when complete.

This is useful for signaling that a critical section is in progress.

Return

the result of block

Parameters

block

the code to execute within the critical section

Type Parameters

T

the return type of the block