DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
dueca::ActivityCallback Class Reference

The most common type of activity, one which uses a GenericCallback object to call something. More...

#include <Activity.hxx>

Inheritance diagram for dueca::ActivityCallback:
Inheritance graph
[legend]
Collaboration diagram for dueca::ActivityCallback:
Collaboration graph
[legend]

Public Member Functions

 ActivityCallback (const GlobalId &owner, const char *my_name, GenericCallback *f, const PrioritySpec &spec)
 Constructor.
 
 ~ActivityCallback ()
 Destructor.
 
- Public Member Functions inherited from dueca::Activity
 Activity (const GlobalId &owner, const char *my_name, const PrioritySpec &s)
 Constructor.
 
virtual ~Activity ()
 Destructor.
 
void switchOn (const TimeTickType &time=0)
 Specify the time from which the Activity is switched on.
 
void switchOff (const TimeTickType &time=0)
 Specify the time when this Activity should be switched off.
 
void switchOn (const TimeSpec &time)
 Specify the time from which the Activity is switched on.
 
void switchOff (const TimeSpec &time)
 Specify the time when this Activity should be switched off.
 
void setTimeSpec (const TimeSpec &ts)
 Supply a periodic time specification to the activity.
 
void changePriority (const PrioritySpec &s)
 Change the priority spec.
 
void print (ostream &os)
 Print to stream, for debugging purposes.
 
int noScheduledBehind () const
 Find out how many more instances of this activity are scheduled.
 
int numScheduledBehind () const
 Find out how many more instances of this activity are scheduled.
 
TimingCheckgetCheck ()
 Return a pointer to the check associated with this activity.
 
const vstringgetName () const
 Return the name of the activity.
 
const std::string & getTargetName () const
 As an activity target.
 
void logBlockingWait ()
 If your activity does blocking waits (file io etc.), it might be neat to report that, so that logging facilities can correctly interpret run times.
 
void logBlockingWaitOver ()
 Report that the blocking wait is over.
 
bool firstCycle (const TimeSpec &ts=TimeSpec(0, 0))
 Is this the first run after the activity has been switched on?
 
bool lastCycle (const TimeSpec &ts=TimeSpec(0, 0))
 Is this the last cycle before the activity will be switched off?
 
bool isBraking ()
 Indicate that the system has been commanded to stop.
 

Friends

class ActivityItem
 Only an ActivityItem may use despatch.
 

Additional Inherited Members

- Public Types inherited from dueca::Activity
enum  RunState {
  Off , Last , Ready , Braking ,
  Running , ReadyWork , FirstWork , RunningWork ,
  BrakingWork , LastWork
}
 To track the run state, and signal about first/last/work etc. More...
 
- Public Attributes inherited from dueca::Activity
GlobalId owner
 Owner of this activity.
 
int activity_id
 Integer handle, unique within a node.
 
PrioritySpec prio_spec
 Priority of the activity.
 
RunState run_state
 Runstate of the activity, to save cycles on switch logic.
 
TimeTickType switch_on
 Indicates the time from which this activity is switched on.
 
TimeTickType switch_off
 Indicates the time until which this activity is switched on.
 
PeriodicTimeSpectime_spec
 Periodic timing specification for this activity.
 
TimingCheckcheck
 Pointer to a TimingCheck object.
 
ActivityManager * my_manager
 A pointer to this activity's ActivityManager.
 
int no_schedules
 Count of the number of times the activity has been scheduled.
 
int no_despatches
 Count of the number of times the activity has been run.
 
vstring name
 string format name.
 
- Protected Member Functions inherited from dueca::Activity
int getOrder () const
 Return the "order" part of the priority.
 
const GlobalIdgetOwner ()
 Return the id of the owner of the activity.
 
bool isInRunPeriod (const DataTimeSpec &ts)
 Test whether activation is appropriate.
 
DataTimeSpec trimToRunPeriod (const DataTimeSpec &ts)
 Trim a time spec to the run period.
 
unsigned int getDescriptionId () const
 Return the id of the activity.
 
void trigger (const DataTimeSpec &t, unsigned idx)
 Override of the trigger method from the TriggerTarget class.
 

Detailed Description

The most common type of activity, one which uses a GenericCallback object to call something.

Use objects of this class if you want to "do" something in a DUECA process. The common use is to create a Callback object which calls back a function in your class, and then create an ActivityCallback object that takes the Callback object as an argument. Then, as needed, switch the Activity on and off, and supply a PeriodicTimeSpec to your own taste.

In your header

ActivityCallback my_activity;
The most common type of activity, one which uses a GenericCallback object to call something.
Definition Activity.hxx:337
This is a "light weight object" that enables you to read the latest set of data on a StreamChannelEnd...
Definition StreamReaderLatest.hxx:43

In the initialisation list of your constructor:

cb(this, &MyClass::OneOfMyFunctions),
my_activity(getId(), "my activity", &cb, priority_spec),

Where OneOfMyFunctions has to have the following type:

void OneOfMyFunctions(const TimeSpec& ts);
A TimeSpec is a specification for a time interval.
Definition TimeSpec.hxx:71

Commonly used member functions are:

Constructor & Destructor Documentation

◆ ActivityCallback()

dueca::ActivityCallback::ActivityCallback ( const GlobalId & owner,
const char * my_name,
GenericCallback * f,
const PrioritySpec & spec )

Constructor.

Constructing an ActivityCallback object is a metafor for allocating/requesting thread of control from DUECA.

Parameters
ownerYour own id
my_nameA name (character string) for the Activity
fGenericCallback object
specPriority specification.

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