Beamlib 3.1.2
This is the Beam C++ class library.
Loading...
Searching...
No Matches
BTask.h
Go to the documentation of this file.
1/*******************************************************************************
2 * BTask.h BTask class
3 * T.Barnaby, Beam Ltd, 2012-11-12
4 * Copyright (c) 2022 All Right Reserved, Beam Ltd, https://www.beam.ltd.uk
5 * For license see LICENSE.txt at the root of the beamlib source tree.
6 *******************************************************************************
7 *
8 * Stack size of 0 assumes system will grow using MMU.
9 * Task priorities can be set from 0 to 4 inclusive. Basic default and idle priority is 0.
10 */
11#ifndef BTask_h
12#define BTask_h
13
14#include <BError.h>
15#include <pthread.h>
16
18class BTask {
19public:
20 BTask(const char* name = "", BUInt stackSize = 0, BUInt priority = 1);
21 virtual ~BTask();
22
23 void init(const char* name, BUInt stackSize = 0, BUInt priority = 1);
24 BError start();
25 void stop();
26 void waitForCompletion();
27
28 // Task manipulation
29 int setPriority(BUInt priority);
30
31 // Task operation
32 virtual void run();
33
34protected:
35 static void* taskFunc(void*);
36
37 const char* oname;
41 pthread_t othread;
43};
44#endif
BUInt32 BUInt
Definition: BTypes.h:33
bool Bool
Definition: BTypes.h:18
Error return class. This class is used to return the error status from a function....
Definition: BError.h:31
Implements a thread of execution.
Definition: BTask.h:18
BUInt opriority
Definition: BTask.h:40
BUInt opolicy
Definition: BTask.h:39
virtual ~BTask()
Definition: BTask.cpp:31
static void * taskFunc(void *)
Definition: BTask.cpp:13
const char * oname
Definition: BTask.h:37
void waitForCompletion()
Definition: BTask.cpp:96
BError start()
Starts the task running.
Definition: BTask.cpp:64
void stop()
Definition: BTask.cpp:89
int setPriority(BUInt priority)
Set the priority of the task: 0 upwards.
Definition: BTask.cpp:109
void init(const char *name, BUInt stackSize=0, BUInt priority=1)
Definition: BTask.cpp:36
Bool orunning
Definition: BTask.h:42
virtual void run()
Definition: BTask.cpp:103
BUInt ostackSize
Definition: BTask.h:38
pthread_t othread
Definition: BTask.h:41