Executor framework with future-based task submission and pluggable thread execution engines
Go to file
Tristan B. Velloza Kildaire fb4cc5bfc9 Executor
- Fixed `isSupportedReturn` check
- Also fixed the future builder
2023-10-01 21:46:00 +02:00
.github/workflows Update d.yml 2023-10-01 15:17:40 +02:00
branding Branding 2023-10-01 17:07:11 +02:00
source/guillotine Executor 2023-10-01 21:46:00 +02:00
.gitignore - Updated `.gitignore` 2023-06-25 19:23:43 +02:00
README.md README 2023-10-01 17:06:06 +02:00
dub.json Dub 2023-06-26 08:38:58 +02:00

README.md

guillotine

D DUB DUB DUB Coverage Status

Executor framework with future-based task submission and pluggable thread execution engines

Usage

You can add this to your project easily by using:

dub add guillotine

API

The full API is documented at here.

Example

Tests the submission of three tasks using the Sequential provider and with the first two tasks having values to return and the last having nothing.

import guillotine.providers.sequential;
import guillotine.executor;
import guillotine.future;
import guillotine.result;
import guillotine.provider;

Provider provider = new Sequential();

// Start the provider so it can execute
// submitted tasks
provider.start();

// Create an executor with this provider
Executor t = new Executor(provider);


// Submit a few tasks
Future fut1 = t.submitTask!(hi);
Future fut2 = t.submitTask!(hiFloat);
Future fut3 = t.submitTask!(hiVoid);

// Await on the first task
writeln("Fut1 waiting...");
Result res1 = fut1.await();
writeln("Fut1 done with: '", res1.getValue().value.integer, "'");

// Stops the internal task runner thread
provider.stop();

Let's also define those functions we are using:

public int hi()
{
    writeln("Let's go hi()!");

    // Pretend to do some work
    Thread.sleep(dur!("seconds")(2));

    return 69;
}

public float hiFloat()
{
    writeln("Let's go hiFloat()!");

    // Pretend to do some work
    Thread.sleep(dur!("seconds")(10));
    
    return 69.420;
}

public void hiVoid()
{
    writeln("Let's go hiVoid()!");

    // Pretend to do some work
    Thread.sleep(dur!("seconds")(10));
}