Search in sources :

Example 1 with CloseByteChannelEvent

use of org.ballerinalang.nativeimpl.io.events.bytes.CloseByteChannelEvent in project ballerina by ballerina-lang.

the class IOUtils method close.

/**
 * Closes the channel asynchronously.
 *
 * @param byteChannel  channel which should be closed.
 * @param eventContext context of the event.
 * @param function     callback function which will be triggered.
 */
public static void close(Channel byteChannel, EventContext eventContext, Function<EventResult, EventResult> function) {
    CloseByteChannelEvent closeEvent = new CloseByteChannelEvent(byteChannel, eventContext);
    CompletableFuture<EventResult> future = EventManager.getInstance().publish(closeEvent);
    future.thenApply(function);
}
Also used : CloseByteChannelEvent(org.ballerinalang.nativeimpl.io.events.bytes.CloseByteChannelEvent) EventResult(org.ballerinalang.nativeimpl.io.events.EventResult)

Aggregations

EventResult (org.ballerinalang.nativeimpl.io.events.EventResult)1 CloseByteChannelEvent (org.ballerinalang.nativeimpl.io.events.bytes.CloseByteChannelEvent)1