tasks, async await, actors and channels for java

Overview

AsyncUtils

tasks, async, await, actors and channels for java

This project tries to explore several approaches to simplify async/concurrent programming in Java. AsyncUtils basically consits of distilled versions of patterns that I implemented over the past years. The purpose isn't best-in class performance but rather reliability.

Sharing mutable state is usually avoided in concurrent programming. We use actors to reduce the negative impact of shared mutable state. Currently, there's only a reflection based actor. It will serve as prototype for VMF actors currently in development.

WARNING: WIP, needs Project Loom to unleash its full potential. The API might change over time.

Structured concurrency with Task Groups

Consider the following code:

// sequential
System.out.println("starting sequential:");
for(int i = 0; i < N; i++) {
    doSomethingThatTakesAWhile();       // runs sequentially
}

Java offers multiple APIs to execute methods concurrently. But these APIs are a little baroque. AsyncUtils provides simpler APIs for that purpose.

Here's how we can perform the method calls inside the loop concurrently:

// concurrent
System.out.println("starting concurrent:");
Tasks.group(g -> {
    for(int i = 0; i < N; i++) {
       g.async(()->doSomethingThatTakesAWhile()); // runs concurrently
    }
}).await();

// continues after all tasks have been executed

Of course, we could use Streams, Fork-Join APIs and Futures. But either the APIs require a lot of boilerplate code or they lack features such as control over how exceptions are handled or how to specify how many threads should be used to process the tasks.

You might also like...

A Java library for capturing, crafting, and sending packets.

A Java library for capturing, crafting, and sending packets.

Japanese Logos Pcap4J Pcap4J is a Java library for capturing, crafting and sending packets. Pcap4J wraps a native packet capture library (libpcap, Win

Dec 30, 2022

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.

Socket.IO-client Java This is the Socket.IO Client Library for Java, which is simply ported from the JavaScript client. See also: Android chat demo en

Jan 4, 2023

Asynchronous Http and WebSocket Client library for Java

Async Http Client Follow @AsyncHttpClient on Twitter. The AsyncHttpClient (AHC) library allows Java applications to easily execute HTTP requests and a

Dec 31, 2022

API gateway for REST and SOAP written in Java.

API gateway for REST and SOAP written in Java.

Dec 31, 2022

A barebones WebSocket client and server implementation written in 100% Java.

Java WebSockets This repository contains a barebones WebSocket server and client implementation written in 100% Java. The underlying classes are imple

Dec 30, 2022

A Java event based WebSocket and HTTP server

Webbit - A Java event based WebSocket and HTTP server Getting it Prebuilt JARs are available from the central Maven repository or the Sonatype Maven r

Dec 23, 2022

A small java project consisting of Client and Server, that communicate via TCP/UDP protocols.

A small java project consisting of Client and Server, that communicate via TCP/UDP protocols.

Ninja Battle A small java project consisting of Client and Server, that communicate via TCP/UDP protocols. Client The client is equipped with a menu i

Jan 14, 2022

A Java library that implements a ByteChannel interface over SSLEngine, enabling easy-to-use (socket-like) TLS for Java applications.

TLS Channel TLS Channel is a library that implements a ByteChannel interface over a TLS (Transport Layer Security) connection. It delegates all crypto

Dec 31, 2022

Socket.IO server implemented on Java. Realtime java framework

Netty-socketio Overview This project is an open-source Java implementation of Socket.IO server. Based on Netty server framework. Checkout Demo project

Dec 30, 2022
Releases(v0.1.1)
Owner
Michael Hoffer
Computer Scientist, Developer, Artist
Michael Hoffer
WebSocket server with creatable/joinable channels.

bytesocks ?? bytesocks is a WebSocket server which allows clients to create "channels" and send messages in them. It's effectively an add-on for byteb

lucko 6 Nov 29, 2022
Library for composability of interdependent non-blocking I/O tasks

Composer Composer helps you to organize and execute multiple interdependent asynchronous input/output tasks such as webservice calls, database read/wr

krupal 19 Oct 8, 2021
Standalone Play WS, an async HTTP client with fluent API

Play WS Standalone Play WS is a powerful HTTP Client library, originally developed by the Play team for use with Play Framework. It uses AsyncHttpClie

Play Framework 213 Dec 15, 2022
Java library for representing, parsing and encoding URNs as in RFC2141 and RFC8141

urnlib Java library for representing, parsing and encoding URNs as specified in RFC 2141 and RFC 8141. The initial URN RFC 2141 of May 1997 was supers

SLUB 24 May 10, 2022
Telegram API Client and Telegram BOT API Library and Framework in Pure java.

Javagram Telegram API Client and Telegram Bot API library and framework in pure Java. Hello Telegram You can use Javagram for both Telegram API Client

Java For Everything 3 Oct 17, 2021
Pcap editing and replay tools for *NIX and Windows - Users please download source from

Tcpreplay Tcpreplay is a suite of GPLv3 licensed utilities for UNIX (and Win32 under Cygwin) operating systems for editing and replaying network traff

AppNeta, Inc. 956 Dec 30, 2022
Android application allowing to sniff and inject Zigbee, Mosart and Enhanced ShockBurst packets on a Samsung Galaxy S20

RadioSploit 1.0 This Android application allows to sniff and inject Zigbee, Mosart and Enhanced ShockBurst packets from a Samsung Galaxy S20 smartphon

Romain Cayre 52 Nov 1, 2022
An annotation-based Java library for creating Thrift serializable types and services.

Drift Drift is an easy-to-use, annotation-based Java library for creating Thrift clients and serializable types. The client library is similar to JAX-

null 225 Dec 24, 2022
ssh, scp and sftp for java

sshj - SSHv2 library for Java To get started, have a look at one of the examples. Hopefully you will find the API pleasant to work with :) Getting SSH

Jeroen van Erp 2.2k Jan 8, 2023