Taskolib  1.3.3
Taskolib Documentation

Taskolib is a library for automating processes. Its main automatization unit is a sequence of steps which are executed in order or through control flow statements. The behavior of each step is defined in the Lua scripting language.

The library provides the main modeling classes for sequences and steps, functionality for executing them in the current thread or in a parallel one, as well as serialization support for saving and loading them.

Create a sequence and run it in the current thread

The C++ classes for modeling sequences and steps are Sequence and Step. A sequence acts like a container for steps and can be executed in the current thread with the member function Sequence::execute():

using namespace task;
Sequence create_sequence()
{
// Create some steps
Step step1{ Step::type_action };
step1.set_script("a = 42");
Step step2{ Step::type_action };
step2.set_script("print('Mary had a little lamb.')");
// Assemble the steps into a sequence
Sequence sequence{ "An example sequence" };
sequence.push_back(step1);
sequence.push_back(step2);
return sequence;
}
Sequence sequence = create_sequence();
Context context; // A context may contain additional information for the sequence
// Run the sequence
sequence.execute(context);
@ type_action
Definition: Step.h:58
Namespace task contains all Taskolib functions and classes.
Definition: CommChannel.h:33
Main include file for Taskolib.

Run a sequence in a parallel thread

Taskolib can start a sequence in a parallel thread via an Executor object. The main thread should frequently call update() on this object to get information about the status of the execution. No other synchronization is necessary.

using namespace task;
Executor ex;
Sequence sequence = create_sequence(); // get a Sequence from somewhere
Context context;
// Start executing a copy of the sequence in a separate thread
ex.run_asynchronously(sequence, context);
// Periodically call update() to bring our local copy of the sequence in sync with the
// other thread. Once the sequence has finished, update() returns false and the thread
// is joined automatically.
while (ex.update(sequence))
sleep(0.1s);

Usage Notes

Taskolib requires at least C++17. All functions and classes are declared in the namespace task. To use the library, include the single header file taskolib/taskolib.h and link your code against both this library and the General Utility Library (-ltaskolib -lgul14).

The evolving design goals of the library are documented in a series of Design Documents.

Authors
Lars Fröhlich, Olaf Hensler, Ulf Fini Jastrow, Marcus Walla (for third-party code see Copyright Notices)