canAllocate

fun canAllocate(amountNeeded: Int = 1): Boolean

A resource may fill a request in many ways. This function indicates if the request for the amount needed can be allocated immediately, without any wait based on the current state of the resource. Since the underlying state of the resource may be more complex than indicated by the state exposed in the API, it is important to use this method to determine if the requested amount can be allocated.

Return

true means that the amount needed can be allocated at the current time

Parameters

amountNeeded

the amount needed from the resource