Task Manager

A TaskManager is actually the pairs of components and the tasks constructed corresponding to those components. In Jusdl, models are simulated by individually evolving the components. This individual evolution of components is performed by defining components individually and constructing tasks for each components. The jobs that are defined in these tasks are defined to make the components evolve by reading its time, input, compute its output. During this evolution, the tasks may fail because any inconsistency. Right after the failure of a task, its not possible for the component corresponding to the task to evolve any more. As the data flows through the components that connects the components, model simulation gets stuck. To keep track of the task launched for each component, a TaskManager is used. Before starting to simulate a model, a TaskManager is constructed for the model components. During the initialization of simulation, tasks corresponding to the components of the model is launched and the pair of component and component task is recorded in the TaskManager of the model. During the run stage of the simulation, TaskManager keeps track of the component tasks. In case any failure in components tasks, the cause of the failure can be investigated with TaskManager.

Full API

Jusdl.Models.ComponentTaskType
ComponentTask(triggertask, outputtask)

Constructs a ComponentTask from triggertask and outputtask. triggertask is the task constructed for the evolution of components and outputtask task is contructed to make the output busses of the components writable.

Example

julia> gen = SinewaveGenerator()
SinewaveGenerator(amp:1.0, freq:1.0, phase:0.0, offset:0.0, delay:0.0)

julia> taskpair = launch(gen)
(Task (runnable) @0x00007f4de65544f0, Task (runnable) @0x00007f4de5e8fd00)

julia> comptask = ComponentTask(taskpair)
ComponentTask{Task,Task}(Task (runnable) @0x00007f4de65544f0, Task (runnable) @0x00007f4de5e8fd00)
source
Jusdl.Models.TaskManagerType
TaskManager(pairs)

Constructs a TaskManager with pairs. pairs is a dictionary whose keys are components and values are component tasks. Component tasks are constructed correponding to the components. A TaskManager is used to keep track of the component task launched corresponding to components.

TaskManager()

Constructs a TaskManager with empty `pairs.

Example

julia> tm = TaskManager()  # A TaskManager with empty pairs
TaskManager(pairs:Dict{Any,Any}())

julia> gen = SinewaveGenerator()  # A component
SinewaveGenerator(amp:1.0, freq:1.0, phase:0.0, offset:0.0, delay:0.0)

julia> ct = ComponentTask(launch(gen))  # A component task corresponding to gen
ComponentTask{Task,Task}(Task (runnable) @0x00007f4de1a0d390, Task (runnable) @0x00007f4de1a0d120)

julia> tm.pairs[gen] = ct  # Write a component and compontent task pair into TaskManager
ComponentTask{Task,Task}(Task (runnable) @0x00007f4de1a0d390, Task (runnable) @0x00007f4de1a0d120)

julia> println(tm.pairs)
Dict{Any,Any}(SinewaveGenerator(amp:1.0, freq:1.0, phase:0.0, offset:0.0, delay:0.0) => ComponentTask{Task,Task}(Task (runnable) @0x00007f4de1a0d390, Task (runnable) @0x00007f4de1a0d120))
source
Base.istaskfailedFunction
istaskfailed(task::Nothing)

Returns false.

istaskfailed(comptask::ComponentTask)

Returns true is triggertask or outputtask of comptask is failed. See also: ComponentTask

source
Jusdl.Models.istaskrunningFunction
istaskrunning(task::Task)

Returns true is the state of task is runnable.

istaskrunning(task::Nothing)

Returns true

istaskrunning(comptask::ComponentTask)

Returns true if triggertask and outputtask of comptask is running. See also: ComponentTask

source
Base.istaskdoneFunction
istaskrunning(task::Nothing)

Returns true

istaskdone(comptask::ComponentTask)

Returns true if the state of triggertask and outputtask of comptask is done. See also: ComponentTask

source