All Projects → GuuJiang → Jacob

GuuJiang / Jacob

Licence: BSD-3-Clause License
A lightweight library to provide coroutines in Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Jacob

Flow
C# co-routine Kernel for .Net. Includes Futures, Barriers, Triggers, Timers and Groups. Gamasutra article provides extra documentation.
Stars: ✭ 59 (+321.43%)
Mutual labels:  coroutines, coroutine
Mvvmtemplate
An Android Template with MVVM and Clean Architecture
Stars: ✭ 182 (+1200%)
Mutual labels:  coroutines, coroutine
Fiber Ext
stackful-coroutines for PHP
Stars: ✭ 142 (+914.29%)
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 (+3607.14%)
Mutual labels:  coroutines, coroutine
Groupco
PHP的服务化框架。适用于Api、Http Server、Rpc Server;帮助原生PHP项目转向微服务化。出色的性能与支持高并发的协程相结合
Stars: ✭ 473 (+3278.57%)
Mutual labels:  generator, coroutines
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+4828.57%)
Mutual labels:  coroutines, coroutine
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (+1071.43%)
Mutual labels:  coroutines, coroutine
DeezerClone
This Application using Dagger Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData),Navigation based on MVVM architecture.
Stars: ✭ 81 (+478.57%)
Mutual labels:  coroutines, coroutine
Coobjc
coobjc provides coroutine support for Objective-C and Swift. We added await method、generator and actor model like C#、Javascript and Kotlin. For convenience, we added coroutine categories for some Foundation and UIKit API in cokit framework like NSFileManager, JSON, NSData, UIImage etc. We also add tuple support in coobjc.
Stars: ✭ 3,921 (+27907.14%)
Mutual labels:  generator, coroutine
Co2
A C++ await/yield emulation library for stackless coroutine
Stars: ✭ 278 (+1885.71%)
Mutual labels:  generator, coroutines
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (+2328.57%)
Mutual labels:  coroutines, coroutine
May
rust stackful coroutine library
Stars: ✭ 909 (+6392.86%)
Mutual labels:  generator, coroutines
Coroutine
C++ 20 Coroutines in Action (Helpers + Test Code Examples)
Stars: ✭ 262 (+1771.43%)
Mutual labels:  coroutines, coroutine
Tascalate Javaflow
Continuations / CoRoutines for Java 1.5 - 11, build tools, CDI support. This project is based on completely re-worked Apache Jakarta Commons JavaFlow library.
Stars: ✭ 51 (+264.29%)
Mutual labels:  coroutines, coroutine
Co
Art of C++. Flag, logging, unit-test, json, go-style coroutine and more.
Stars: ✭ 2,264 (+16071.43%)
Mutual labels:  coroutines, coroutine
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (+921.43%)
Mutual labels:  coroutines, coroutine
Genawaiter
Stackless generators on stable Rust.
Stars: ✭ 263 (+1778.57%)
Mutual labels:  generator, coroutine
Recoil
Asynchronous coroutines for PHP 7.
Stars: ✭ 765 (+5364.29%)
Mutual labels:  generator, coroutines
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (+42.86%)
Mutual labels:  coroutines, coroutine
kit
C++11 libs: await, channels, reactive/signals, timelines, alarms, logging, args, etc.
Stars: ✭ 21 (+50%)
Mutual labels:  coroutines

Jacob

A lightweight library to provide coroutines in Java

Usage

add dependency for jacob-core

<dependency>
    <groupId>com.guujiang</groupId>
    <artifactId>jacob-core</artifactId>
    <version>0.0.1</version>
</dependency>

write a class contains one or more generator methods.

A generator method is a method which returns Iterable and generate some values in the middle with the yield method.
Here is a example.

// strongly recomended to import the yield method as static to make the syntax more natural
import static com.guujiang.jacob.Stub.yield;

import com.guujiang.jacob.annotation.Generator;
import com.guujiang.jacob.annotation.GeneratorMethod;

// add the @Generator annotation to class
@Generator
class Generator {

    // add the @GeneratorMethod to methods
    @GeneratorMethod
    public Iterator<Integer> someMethod() {
        for (int i = 0; i < 5; ++i) {
            // call the yield method whenever you want to "return" a value out
            yield(i);
        }

        // a return statement must be added in the end to make the compiler happy
        // the return value does not matter, offen use null
        return null;
    }
}

Enhance the bytecode

jacob convert your normal Java method into coroutine with bytecode manuplation, which can happen at two points. You only need to choose one of them.

  1. Enhance at the compile time.(recommended)
    add the following plugin to your maven project's pom.xml.
<plugin>
    <groupId>com.guujiang</groupId>
    <artifactId>jacob-maven-plugin</artifactId>
    <version>0.0.1</version>
    <executions>
        <execution>
            <goals>
                <goal>enhance</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Package jar file with mvn package, the plugin will automatically convert all the classed with proper annotations into coroutine form. Then you just need to execute the generated jar file or use as dependency.

  1. Enhance at runtime.
    If you cannot enhance the classes at compile time, you can also do it at classloading.
    First compile the jacob-core project with mvn package to get a file called jacob.jar. Then add the following parameters to your java command line when launch the program which used the generator code.
-javaagent:<path of jacob.jar>

For more information, refer to the jacob-samples project

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].