Coder Social home page Coder Social logo

dag's Introduction

This experimental library helps to organize tasks and its dependencies. Amphp framework support provide ability to execute tasks asynchronously.

Following example show basic usage:

$taskDag = (new TaskGraph())
    
    // root task in graph (there might be multiple root tasks)
    ->addTask(new ClosureTask('1', function () {
        echo $this->name;
    }))
    
    // these two tasks were be executed only after task with name '1'
    // the order of execution is not guaranteed
    ->addTask(new ClosureTask('2', function () {
        echo 2;
    }, ['1'])) 
    ->addTask(new ClosureTask('3', function () {
        echo 3;
    }, ['1']))

    // this is the last task in graph (there might be multiple leaf tasks)
    ->addTask(new ClosureTask('4', function () {
        echo 4;
    }, ['3', '2']));

Amp\Loop::run($taskDag); // will output "1234"

The visualization of the execution graph will be following:

     +------+
   +-+Task 1+-+
   | +------+ |
   |          |
+--v---+  +---v--+
|Task 2|  |Task 3|
+--+---+  +---+--+
   |          |
   | +------+ |
   +->Task 4<-+
     +------+

dag's People

Contributors

dbalabka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mushu777

dag's Issues

Task Names

IMO task names should be assigned on addTask instead of inside the task implementations. That allows having one implementation used multiple times, e.g.

$x->addTask('copy.js', new CopyTask('**/*.js', 'build'));
$x->addTask('copy.css', new CopyTask('**/*.css', 'build'));

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.