All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.datakernel.async.callback.Callback Maven / Gradle / Ivy

Go to download

Efficient non-blocking network and file I/O, for building Node.js-like client/server applications with high performance requirements. It is similar to Event Loop in Node.js. Although Eventloop runs in a single thread, multiple event loops can be launched at the same time allowing for efficient CPU usage.

The newest version!
package io.datakernel.async.callback;

import io.datakernel.eventloop.Eventloop;
import org.jetbrains.annotations.Nullable;

/**
 * Represents a universal Callback interface
 */
@FunctionalInterface
public interface Callback {
	/**
	 * Performs action upon of completion of Completable computation
	 */
	void accept(T result, @Nullable Throwable e);

	static  Callback toAnotherEventloop(Eventloop anotherEventloop, Callback cb) {
		return (result, e) -> anotherEventloop.execute(() -> cb.accept(result, e));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy