waitRelease

suspend fun SmartSemaphore.waitRelease(permits: Int = 1): Int

Will wait until the SmartSemaphore.permitsStateFlow of this instance will have permits count free permits.

Anyway, after the end of this block there are no any guaranties that SmartSemaphore.freePermits>= permits due to the fact that some other parties may lock it again