Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/naoty/circuit

[WIP] A runner for serial or parallel tasks
https://github.com/naoty/circuit

Last synced: 21 days ago
JSON representation

[WIP] A runner for serial or parallel tasks

Awesome Lists containing this project

README

        

# Circuit

A runner for serial or parallel tasks.

## Usage

### Single task

```java
Task task = new Task() {
@Override
public Integer run(String text) {
return text.length();
}
};

task.run("Hello, world!"); //=> 13
```

### Serial tasks

```java
// task1 -> task2 -> task3
Task tasks = new SerialTasks.Builder(task1)
.add(task2)
.add(task3)
.build();
tasks.run("Hello, world!");
```

### Parallel tasks

```java
// [task1, task2]
Task tasks = new ParallelTasks.Builder()
.add(task1)
.add(task2)
.build();
tasks.run(3);
```

### Compound tasks

```java
// task1 -> [task2, task3] -> task4
Task subtasks = ParallelTasks.Builder()
.add(task2)
.add(task3)
.build()
Task tasks = SerialTasks.Builder(task1)
.add(subtasks)
.add(task4)
.build();
tasks.run("Hello, world!");
```

## Installation

```groovy
dependencies {
compile "com.github.naoty:circuit:+"
}
```

## Author

[naoty](https://github.com/naoty)