receiveFromChannel

fun receiveFromChannel(condition: Predicate<T>, waitStats: Boolean = true): List<T>(source)

Finds the items in the channel according to the condition and removes them directly, skipping the line of waiting requests. The channel must not be empty, and no waiting request can want any of the items found; otherwise an IllegalStateException will occur and nothing is removed. Use availableForRemoval() to take only the items that no request wants.

Return

a list of the items found. May be empty if nothing is found that matches the condition.

Parameters

condition

the criteria for selecting the items

waitStats

indicates whether waiting time statistics should be collected