All Projects → vsilaev → Tascalate Javaflow

vsilaev / Tascalate Javaflow

Licence: apache-2.0
Continuations / CoRoutines for Java 1.5 - 11, build tools, CDI support. This project is based on completely re-worked Apache Jakarta Commons JavaFlow library.

Programming Languages

java
68154 projects - #9 most used programming language
java8
65 projects

Projects that are alternatives of or similar to Tascalate Javaflow

Flow
C# co-routine Kernel for .Net. Includes Futures, Barriers, Triggers, Timers and Groups. Gamasutra article provides extra documentation.
Stars: ✭ 59 (+15.69%)
Mutual labels:  coroutines, coroutine
Mvvmtemplate
An Android Template with MVVM and Clean Architecture
Stars: ✭ 182 (+256.86%)
Mutual labels:  coroutines, coroutine
Fiber Ext
stackful-coroutines for PHP
Stars: ✭ 142 (+178.43%)
Mutual labels:  coroutines, coroutine
Co
Art of C++. Flag, logging, unit-test, json, go-style coroutine and more.
Stars: ✭ 2,264 (+4339.22%)
Mutual labels:  coroutine, coroutines
Coroutine
C++ 20 Coroutines in Action (Helpers + Test Code Examples)
Stars: ✭ 262 (+413.73%)
Mutual labels:  coroutines, coroutine
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (+180.39%)
Mutual labels:  coroutines, coroutine
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (+221.57%)
Mutual labels:  coroutines, coroutine
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-60.78%)
Mutual labels:  coroutines, coroutine
DeezerClone
This Application using Dagger Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData),Navigation based on MVVM architecture.
Stars: ✭ 81 (+58.82%)
Mutual labels:  coroutines, coroutine
Jacob
A lightweight library to provide coroutines in Java
Stars: ✭ 14 (-72.55%)
Mutual labels:  coroutines, coroutine
Libfiber
The high performance coroutine library for Linux/FreeBSD/MacOS/Windows, supporting select/poll/epoll/kqueue/iocp/windows GUI
Stars: ✭ 519 (+917.65%)
Mutual labels:  coroutines, coroutine
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (+566.67%)
Mutual labels:  coroutines, coroutine
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+1252.94%)
Mutual labels:  coroutines, coroutine
Myweatherkotlinflow
Android app that shows weather at your current location or any custom location you specify. Uses Kotlin Flow for data streaming and coroutines for asynchronous work. Also leverages Room, navigation component, Viewmodel and Livedata Jetpack components with MVVM presentation layer architecture. Dagger 2 with Dagger android for dependency injection
Stars: ✭ 23 (-54.9%)
Mutual labels:  coroutines
Handle Path Oz
Android Library to handle multiple Uri's(paths) received through Intents.
Stars: ✭ 36 (-29.41%)
Mutual labels:  coroutines
Sylar
C++高性能分布式服务器框架,webserver,websocket server,自定义tcp_server(包含日志模块,配置模块,线程模块,协程模块,协程调度模块,io协程调度模块,hook模块,socket模块,bytearray序列化,http模块,TcpServer模块,Websocket模块,Https模块等, Smtp邮件模块, MySQL, SQLite3, ORM,Redis,Zookeeper)
Stars: ✭ 895 (+1654.9%)
Mutual labels:  coroutine
May actor
Local Actor library based on may
Stars: ✭ 19 (-62.75%)
Mutual labels:  coroutine
Mvvm Kotlin Android Architecture
MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit5
Stars: ✭ 1,014 (+1888.24%)
Mutual labels:  coroutines
Plainupnp
PlainUPnP is an upnp control point application for android.
Stars: ✭ 33 (-35.29%)
Mutual labels:  coroutines
Storagedone Android
Kotlin library to make easy using local document-oriented database in Android apps.
Stars: ✭ 18 (-64.71%)
Mutual labels:  coroutines

Maven Central GitHub release license

IMPORTANT NOTICE FOR RELEASE 2.5.0!!!

Java 9+ is fully supported now, all artefacts are modular multi-release JAR-s that works correctly with Java versions 1.6 to 11. The library code was tested with JDK 11, and all features of the Java 11 bytecode (including nest of inner classes) works correctly.

IMPORTANT NOTICE FOR RELEASE 2.3.0!!!

Continuation support for Java

This project contains libary, tools and examples to develop Java applications using continuations.

According to Wikipedia "a continuation is an abstract representation of the control state of a computer program; a continuation reifies the program control state, i.e. the continuation is a data structure that represents the computational process at a given point in the process's execution; the created data structure can be accessed by the programming language, instead of being hidden in the runtime environment"

In other words, continuation allows you to capture execution state of the program (local variables, execution stack, program counters etc.) at the certain places and later resume execution from the saved point. Unfortunately, Java has no support for first-class continuations, but it can be added via bytecode instrumentation (like this library did)

The project is based on the completely reworked Apache Jakarta-Commons JavaFlow project (http://commons.apache.org/sandbox/commons-javaflow/). Below is a list of major changes:

  1. Original JavaFlow instruments bytecode of each and every method available for tooling to add Continuations support. This adds significant overhead to both code size and execution time. The reworked version requires developer to mark Continuation-aware classes/methods explicitly with annotations.
  2. Code is updated to use new bytecode instrumentation tools (ObjectWeb ASM 5.x); support for BCEL is discontinued
  3. Codebase is split to separate modules: run-time API, instrumentation provider SPI, offline instrumentation tools (Maven, Ant, command-line), run-time instrumentation JavaAgent, utilities and examples
  4. The library adds support for recent Java features like lambdas and dynamic dispatch

Maven

You have to add the following configuration to enable build-time instrumentation of classes during Maven build:

	<dependencies>
		<dependency>
			<groupId>net.tascalate.javaflow</groupId>
			<artifactId>net.tascalate.javaflow.api</artifactId>
			<version>2.6.1</version>
		</dependency>
		<!-- Add-on for Java 8 and above -->
		<dependency>
			<groupId>net.tascalate.javaflow</groupId>
			<artifactId>net.tascalate.javaflow.extras</artifactId>
			<version>2.4.1</version>
		</dependency>	
		...
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<!-- versions 1.6 -- 11 are supported -->
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>net.tascalate.javaflow</groupId>
				<artifactId>net.tascalate.javaflow.tools.maven</artifactId>
				<version>2.6.1</version>
				<executions>
					<execution>
						<phase>process-classes</phase>
						<goals>
							<goal>javaflow-enhance</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

Note that if you are using continuations with Java 1.8 lambdas then you need to add Tascalate JavaFlow instrumentation agent at run-time as command-line option, while lambda-related classes are generated by JVM on the fly and there is no other way to instrument them. If this is not an option, then you can de-sugar all lambdas with RetroLambda Maven plugin at build-time (RetroLambda output is supported by Tascalate JavaFlow 2.3.2 or higher).

Please refer to pom.xml in examples project for typical Maven configuration

Ant

There is a separate Ant task for applying JavaFlow instrumentation at build-time.

It's possibe to instrument compiled Java classes as below:

    <target name="instrument-classes" description="JavaFlow Instrumentation" depends="compile">
        <taskdef name="javaflow" classname="org.apache.commons.javaflow.ant.AntRewriteTask" 
        classpathref="ant-lib-classpath"/>
        <echo message="JavaFlow instrumentation of compiled classes in ${classes.dir}" />
        <javaflow srcdir="${classes.dir}" destdir="${i-classes.dir}" classpathref="classpath"/>
    </target>

... as well as re-write packaged JAR file:

    <target name="instrument-jar" description="JavaFlow Instrumentation" depends="jar">
        <taskdef name="javaflow" classname="org.apache.commons.javaflow.ant.AntRewriteTask" 
        classpathref="ant-lib-classpath"/>
        <echo message="JavaFlow instrumentation of compiled classes in ${jar.dir}/${ant.project.name}.jar" />
        <javaflow srcdir="${jar.dir}" destdir="${i-jar.dir}" classpathref="classpath"/>
    </target>

You may download a complete examples project setup from the latest release for complete configuration template. Please pay attention to ant-lib folder with Ant TaskDef and lib folders with compile-/runtime-dependencies.

Java Instrumentation Agent (Runt-time Instrumentation)

As an alternative to compile-time bytecode instrumentation, you MAY use Tascalate JavaFlow Instrumentation Agent from the latest release to enable continuations support at class-loading time. Please note, that if you are using Java 8 and creating continuable lambda functions (either anonymous or/and as method references), and you don't replace them with tools like RetroLambda as mentioned above, then you SHOULD use this instrumentation agent always: as long as Java run-time generates implementation of functional interfaces on the fly there is no other option to instrument them. To enable Tascalate JavaFlow Instrumentation Agent please add the following arguments to Java command line:

    java -javaagent:<path-to-jar>/javaflow.instrument-continuations.jar <rest-of arguments>

The agent JAR file includes all necessary dependencies and requires no additional CLASSPATH settings. It's recommended to use this agent in conjunction with either Maven or Ant build tools supplied to minimize the associated overhead of the instrumentation during class-loading process at run-time.

Another useful application of the instrumentation agent is to apply it for debugging code within your IDE of choice. Just specify the "-javaagent" option listed above in your IDE debug/run configuration and you will be able to perform quick "debug-fix" loops without executing full project rebuild.

Command-line tools

It's possible to use a stand-alone command-line utility JavaFlowRewriteJar.jar to instrument JAR archives containing continuable classes. Please use the following command:

    java -jar JavaFlowRewriteJar.jar src1.jar dst1.jar src2.jar dst2.jar...

Note, that the source and the destination should be different files.

CDI Support

To work correctly in CDI environment continuable methods should be advised only by continuation-aware CDI proxies (interceptors, scope proxies, etc). Obviously, generation of these proxies is out of our control. Plus, major CDI containers (JBoss Weld and Apache OpenWebBeans) generates such proxies dynamically at run-time. Therefore if you plan to use Tascalate JavaFlow continuations with managed beans' methods then it's necessary to instrument CDI-specific proxies with javaflow.instrument-cdi-proxy.jar Java Agent:

    java -javaagent:<path-to-jar>/javaflow.instrument-cdi-proxy.jar <rest-of arguments>

Please note, that CDI-specific agent neither requires javaflow.instrument-continuations.jar to operate correctly nor provides class file transformers for continuable methods. So if your project runs with CDI environment AND uses Java 8 lambdas then you have to add 2 Java agents, every serving different purpose:

    java -javaagent:<path-to-jar>/javaflow.instrument-continuations.jar \
         -javaagent:<path-to-jar>/javaflow.instrument-cdi-proxy.jar \
	 <rest-of arguments>

CDI functionality is tested with JBoss Weld 2.x - 3.1.1 and Apache OpenWebBeans 1.6.x - 2.0.10. Contribution for other CDI/CDI-like containers (Spring, Google Guice, etc) is welcome.

More documentation & exmaples

Examples of the library usage may be found in the Tascalate JavaFlow Examples project. The covered topics are common tasks, inheritance, lambdas support, proxies, usage with CDI containers like JBoss Weld and Apache OpenWebBeans.

For additional documentation, tutorials and guidelines please visit my blog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].