Skip to content

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

Notifications You must be signed in to change notification settings

deavmi/guillotine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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));
}

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages