ikorennoy / jasyncfio

Java asynchronous file I/O based on io_uring Linux interface
Apache License 2.0
72 stars 10 forks source link
asyncronous file-io file-io-in-java io-uring java non-blocking-io

Jasyncfio

Build

Jasyncfio provides an asynchronous file I/O API based on the Linux io_uring interface.

Jasyncfio Features

Examples

EventExecutor eventExecutor = EventExecutor.initDefault();

CompletableFuture<AsyncFile> asyncFileCompletableFuture = AsyncFile.open(Paths.get("path/to/file"), eventExecutor);
AsyncFile file = asyncFileCompletableFuture.get();

ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024);
CompletableFuture<Integer> readCompletableFuture = file.read(byteBuffer);

Integer readBytes = readCompletableFuture.get();

If you want to dive deeper, there are more examples with explanations on the wiki.

Download

Releases are available at Maven Central.

Since the library uses native code, it is necessary to specify the classifier. At the moment there are releases only for linux-amd64, there are plans to support linux-arm64.

Requirements

Maven

<dependency>
    <groupId>one.jasyncfio</groupId>
    <artifactId>jasyncfio</artifactId>
    <version>0.0.8</version>
    <classifier>linux-amd64</classifier>
</dependency>

Gradle Groovy DSL

implementation 'one.jasyncfio:jasyncfio:0.0.8:linux-amd64'

Gradle Kotlin DSL

implementation("one.jasyncfio:jasyncfio:0.0.8:linux-amd64")