Class to support running a background task. More...

#include <Task.h>

Inheritance diagram for Task:

Public Types

enum class  State { Suspended , Sleeping , Running }
 State of a task. More...
 
enum class  Notify {
  None , Suspending , Resuming , Sleeping ,
  Waking
}
 Notification of state change. More...
 

Public Member Functions

virtual ~Task ()
 
bool resume ()
 Call to set task running. More...
 
void suspend ()
 Suspend a task. More...
 
void sleep (unsigned interval)
 Puts the task to sleep for a while. More...
 

Protected Member Functions

virtual void loop ()=0
 Inherited classes override this to perform actual work. More...
 
virtual void onNotify (Notify code)
 Called immediately before calling to loop() to indicate a state change. More...
 

Detailed Description

Class to support running a background task.

Note
A task is implemented by overriding the loop() method to perform some work. All tasks must co-operate to ensure the system runs smoothly. Note that there is no yield() function to call. All tasks share the same stack space.

Member Enumeration Documentation

◆ Notify

enum Task::Notify
strong

Notification of state change.

Enumerator
None 
Suspending 
Resuming 
Sleeping 
Waking 

◆ State

enum Task::State
strong

State of a task.

Enumerator
Suspended 
Sleeping 
Running 

Constructor & Destructor Documentation

◆ ~Task()

virtual Task::~Task ( )
inlinevirtual

Member Function Documentation

◆ loop()

virtual void Task::loop ( )
protectedpure virtual

Inherited classes override this to perform actual work.

Implemented in Jerryscript::Task.

◆ onNotify()

virtual void Task::onNotify ( Notify  code)
inlineprotectedvirtual

Called immediately before calling to loop() to indicate a state change.

◆ resume()

bool Task::resume ( )
inline

Call to set task running.

Return values
booltrue on success, false if task queue is full

◆ sleep()

void Task::sleep ( unsigned  interval)
inline

Puts the task to sleep for a while.

Parameters
intervalTime in milliseconds

◆ suspend()

void Task::suspend ( )
inline

Suspend a task.


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