beatmup.Multitask

class beatmup.Multitask

Conditional multiple tasks execution.

Beatmup offers a number of tools allowing to pipeline several tasks into a single one. This technique is particularly useful for designing complex multi-stage image processing pipelines.

Multitask is the simplest such tool. It allows to concatenate different tasks into a linear conveyor and run them all or selectively. To handle this selection, each task is associated with a repetition policy specifying the conditions whether this given task is executed or ignored when the pipeline is running.

Specifically, there are two extreme modes that force the task execution every time (REPEAT_ALWAYS) or its unconditional skipping (IGNORE_ALWAYS) and two more sophisticated modes with the following behavior:

  • IGNORE_IF_UPTODATE skips the task if no tasks were executed among the ones coming before the current task in the pipeline;

  • REPEAT_UPDATE forces task repetition one time on next run and just after switches the repetition policy to IGNORE_IF_UPTODATE.

__init__(self: beatmup.Multitask) None

Methods

__init__(self)

add_task(self, task)

Adds a new task to the end of the pipeline

get_repetition_policy(self, task)

Returns repetition policy of a specific task in the pipeline.

get_task(self, index)

Retrieves a task by its index

get_task_count(self)

Returns number of tasks in the pipeline

get_task_index(self, holder)

Retrieves task index if it is in the pipeline; returns -1 otherwise

insert_task(self, task, before)

Inserts a task in a specified position of the pipeline before another task

measure(self)

Determines pipeline execution mode and required thread count

remove_task(self, task)

Removes a task from the pipeline, if any.

set_repetition_policy(self, task, policy)

Sets repetition policy of a task.

Attributes

IGNORE_ALWAYS

IGNORE_IF_UPTODATE

REPEAT_ALWAYS

REPEAT_UPDATE