bmv2
Designing your own switch target with bmv2
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Private Member Functions | List of all members
bm::PeriodicTask Class Reference

Private Member Functions

void execute ()
 

Detailed Description

Initializes and registers a task that is to be executed periodically at a fixed interval. Task will execute during the lifetime of the object. If a PeriodicTask object is made a member of an ActionPrimitive class, this will ensure that the task is only executed if the extern represented by the ActionPrimitive is instantiated in P4.

class MyExtern : public ActionPrimitive<> {
MyExtern() : task("my_task",
std::bind(&MyExtern::periodic_fn, this),
std::chrono::seconds(1)) {}
void operator ()() {
// This will execute when extern is called
}
void periodic_fn() {
// This will execute once a second
}
// Note: If `task` is not the last declared member, periodic_fn
// may be called before all members have been initialized
PeriodicTask task;
}

Member Function Documentation

◆ execute()

void bm::PeriodicTask::execute ( )
private

Executes the stored function and sets next to the next desired execution time. To be called by PeriodicTaskList


The documentation for this class was generated from the following file: