Skip to main content

nebula::exec::task::DataTriggeredTask

Data triggered task can be defined by providing a Task implementation and either with a list of elements or a Condition. Elements normally represent named events as explained in nebula::comm::EventElement. Conditions can be used when multiple events are present, and the task need to be triggered only when a particular condition is met. The current implementation support two conditions, they are:

  • condition::AllOfCondition: which is satisfied only when all of the events provided to it have atleast one unprocessed event.

  • condition::AnyOfCondition: which is satisfied only when any of the events provided to it have atleast one unprocessed event.

Example:

// Task definition
Class DataTask : public Task {
// The `run` method will have the implementation for event processing.
// This method will be only called when there are events to process,
// and the condition (if any) mentioned in the DataTriggeredTask is satisfied.
bool run() {
// Implementation
}

// Other task method implementations
};

// Define a EventElement for the named event "Event1 name" using backend `DataProviderImpl`
EventElement<DataProviderImpl> element1{"Event1 name"};
// Define a EventElement for the named event "Event2 name" using backend `DataProviderImpl`
EventElement<DataProviderImpl> element2{"Event2 name"};

// The task instance to do event processing upon triggering.
DataTask dataTask;

// Declare a handler which will trigger `dataTask` instance when either named events "Event1 name" or "Event2 name"
// are available
DataTriggeredTask handler(dataTask, element1, element2);
// Or
// Declare a handler using Condition, which will trigger `dataTask` instance when both named events "Event1 name" and "Event2 name"
// are available
auto triggerCondition = std::make_shared<condition::AllOfCondition>(element1, element2);
DataTriggeredTask handler(dataTask, triggerCondition);

class nebula::exec::task::DataTriggeredTask

Helper to define a data triggered task.

Members

public template<>
inline DataTriggeredTask(Task & task, Elements &... elements)

Construct a new Data Triggered Task object using events.

  • Parameters

    • Task Implementation type of Task
    • Elements Implementation types of Elements
  • Parameters

    • task task object
    • elements event elements

public template<>
inline DataTriggeredTask(Task& task, std::shared_ptr<condition::ConditionBase > cond)

Construct a new Data Triggered Task object with condition.

  • Parameters

    • Task Implementation type of Task
  • Parameters

    • task task object
    • cond event elements

public virtual ~DataTriggeredTask()

Destroy the Data Triggered Task object After this, no more calls to the task will be delivered.