trySend

abstract fun trySend(element: E): ChannelResult<Unit>(source)

Immediately adds the specified element to this channel, if this doesn't violate its capacity restrictions, and returns the successful result. Otherwise, returns failed or closed result. This is synchronous variant of send, which backs off in situations when send suspends or throws.

When trySend call returns a non-successful result, it guarantees that the element was not delivered to the consumer, and it does not call onUndeliveredElement that was installed for this channel. See "Undelivered elements" section in Channel documentation for details on handling undelivered elements.