Giter Club home page Giter Club logo

taskchain's Introduction

TaskChain - Current Release Version: 3.7.2

What is TaskChain?

TaskChain is a Java Control Flow framework designed for Game Developers.

TaskChain helps facilitate running tasks on an application's "Main Thread", and parallel tasks off the main (async to main).

You define a series of tasks (a Task Pipeline) in the order that they should execute, and the registration of each task defines whether it should run on the main thread or not.

TaskChain then executes your task pipe line, switching thread context where needed, passing the result from the previous task to the next.

Documentation / Getting Started

  1. Why you should use TaskChain
  2. Learning TaskChain Terminology
  3. Using TaskChains & Examples
  4. Shared Task Chains

Supported Game Platforms

Currently Supported

Planned

  • Forge Minecraft Servers [#2]

3rd Party

  • Nukkit Minecraft Servers [#13]

Want to add your own game?

If you wish to add support for your own game, see Implementing a new game

JavaDocs

JavaDocs can be found at http://taskchain.aikar.co

Changelog

Please see CHANGELOG

Why does it require Java 8+?

Get off your dinosaur and get on this rocket ship!

On a serious note, Lambdas provided a much cleaner API and easier implementations.

Dinosaurs have been dead for a long time, so get off it before you start to smell.

Download Java 8

Using Kotlin 1.1 for Bukkit Plugins?

If you are a developing Bukkit plugins in Kotlin, we actually do not recommend using TaskChain. @okkero has created a vastly better experience using Coroutines in Kotlin.

We recommend using his framework, Skedule, which requires Kotlin 1.1.

Coroutines are a beautiful way to create this kind of behavior, but sadly we are not able to do that kind of stuff in Java Syntax.

Note that Skedule is only for Bukkit plugins. If you are working in a different platform, TaskChain does still work for Kotlin.

Older Versions

  • v2: Updated to a Java 8 Lambda API. Massive redesign and new features. Very close to v3 but uses a static registration and global state, so it can only be bound to a single Bukkit Plugin
    (note: some bugs were fixed in v3 with Shared chains done and error handlers)

  • v1: The original (ugly) API for Bukkit plugins, pre Java 8. Only version usable below java 8, but probably some bugs.

License

TaskChain (c) Daniel Ennis (Aikar) 2014-2017.

TaskChain is licensed MIT. See LICENSE

taskchain's People

Contributors

aikar avatar gabik21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

taskchain's Issues

Repeat Task until Condition is met

It would be nice to have repeating tasks in the chain.
something like this:

newChain().repeat(c-> c.repeat(c->c.delay(10, TimeUnit.SECONDS).sync(this::updateSigns),6).async(this::updateDB),-1)

would do something like this

while(true){
   for(int i = 0;i<6;i++){
       wait(10, second)
       (sync) updateSigns();
   }
   (async)updateDB();
}

(repeat would take a lambda that does stuff with a new chain that will be executed every time repeat is called)
Don't really know if the way I outlined that api is a good thing to do something like that, but I think the general concept of repeating some parts of a chain n (or -1 for endless) times.

BungeeCord support

Is this possible? I tried implementing myself but I failed on the shutdown hooks (because Bungee doesn't has a proper event or shutdown method)

executeFuture support

An alternative to .execute(), that returns a future that is resolved with the last returned value (if the last is generic/doesnt return, Object is used and null)

If .executeFuture is used, the chain should note that, and any uncaught exception should bubble to the pending future.

Unit Tests

Need an asynchronous testing solution.

Prepend task to shared chain

Is it currently possible to insert into shared chain at the beginning, not the end? I'm using taskchain for queue-like thing and I need to make some tasks high priority.

In the current scenario, I'm adding things to the queue like this:

sharedChain.async(..).asyncFirstCallback(..).sync(..).execute()

Wiki / Readme update

Build some wiki pages with better documentation and examples

spruce up readme even more

How do you even use this?

This project is missing pretty much all usable documentation, same for Spigot and Bukkit and Paper as well. I don't know how anybody learns how to use any of this.

I'm just trying to make a long running task in a separate thread and all I have to go on is old questions people have asked which talked about this project because there's never any proper well-written up-to-date and short and concise tutorials anywhere. A bunch of Spigot threads dumped me here and I'm still lost.

The Usage page on the wiki is all I have on how to use this and it's not even a tutorial, it's just a copy and paste blob of code that doesn't make any kind of sense at all.

Can we start with a HelloWorld tutorial that's as short and simple as possible then progressively explain each and every feature stepping me through bit by bit one at a time with each tutorial being as small, short, and simple as possible until we progress to the intermediate and then advanced stages.

I'm never going to understand any of this without that and I don't see how anybody else can either. Why do developers almost exclusively just give a giant mutli-page blob of code and then expect everyone to figure it out on their own?

Sorry for rant, I feel like I'm climbing mount everest and back just to do the simplest things which adds days and weeks to the simplest plugins because there's almost always never any tutorials anywhere by anyone unless it's 10 years out of date and poorly written. It's often just here's a blob of code or JavaDoc, figure it out yourself.

Folia Support

Will you support folia? Any plans to add Folia support? The project hasn't been updated in quite some time and I am curious if it is abandoned. I find it useful, but if its no longer supported by the developer I will move on. Thanks!

Data Wrapper Chains

any data wrapper based method should be able to return a DataWrappedChain. There should be a chain for 2-6 of each data class.

The chains should provide extra methods so you can access the data properties such as .sync((var1, var2, var3) -> { instead of (data) -> { data.var1

to avoid massive duplication of methods, were going to need to update add0() to be overloaded on a data wrapped chain to call it on the wrapped chain instead of the wrapper

Concerns:

Can we pull this off returning a different object without breaking existing API's?
I think so when adding overloaded versions of each api.

Need to really see if we can break out these API methods into interfaces to start to organize the API names better.

Queue API

Provide an API that can take a queue, and provide a queue processor.

Sync option:
parameters to configure # of elements of the queue to process per run, and how long to wait in between each process of the queue.

game units should use the game scheduler to advance to next run and rl time units should use async delays to control for that (but return to sync)

Async option should also provide optional concurrency level, and delays.

Sponge Support

Major Issue: No API to determine isMainThread

Desire: Use PluginContainer for SpongeTaskChainFactory.create()

Question: HotSwappable

Is it possible to use TaskChains / Lambda's and retain the ability to hotswap the code whilst developing server concepts?

User supplied Queues and Executors

Desire to allow user to supply their own queue to Bukkit/Sponge implementations.

Major Issue:
Right now, a factory is expected to be 1 to 1 relation to its queue.
if factory shuts down, the queue shuts down.

But what if 2 factories share the same queue?

How do we process shutdown of a factory and block until its tasks are flushed from the async queue but allow the other factories to continue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.