Beam-lib  2.16.3
This is the Beam C++ class library.
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) 2012 All Right Reserved, Beam Ltd, http://www.beam.ltd.uk
5  *******************************************************************************
6  *
7  * Stack size of 0 assumes system will grow using MMU.
8  * Task priorities can be set from 0 to 4 inclusive. Basic default and idle priority is 0.
9  */
10 #ifndef BTask_h
11 #define BTask_h
12 
13 #include <BError.h>
14 #include <pthread.h>
15 
16 class BTask {
17 public:
18  BTask(const char* name = "", BUInt stackSize = 0, BUInt priority = 1);
19  virtual ~BTask();
20 
21  void init(const char* name, BUInt stackSize = 0, BUInt priority = 1);
22  BError start();
23  void stop();
24  void waitForCompletion();
25 
26  // Task manipulation
27  int setPriority(BUInt priority);
28 
29  // Task operation
30  virtual void run();
31 
32 protected:
33  static void* taskFunc(void*);
34 
35  const char* oname;
39  pthread_t othread;
41 };
42 #endif
BUInt opolicy
Definition: BTask.h:37
void stop()
Definition: BTask.cpp:88
int setPriority(BUInt priority)
Set the priority of the task: 0 upwards.
Definition: BTask.cpp:108
bool Bool
Definition: BTypes.h:15
Bool orunning
Definition: BTask.h:40
BError start()
Starts the task running.
Definition: BTask.cpp:63
pthread_t othread
Definition: BTask.h:39
const char * oname
Definition: BTask.h:35
BTask(const char *name="", BUInt stackSize=0, BUInt priority=1)
Definition: BTask.cpp:24
BUInt32 BUInt
Definition: BTypes.h:30
static void * taskFunc(void *)
Definition: BTask.cpp:12
BUInt opriority
Definition: BTask.h:38
void waitForCompletion()
Definition: BTask.cpp:95
void init(const char *name, BUInt stackSize=0, BUInt priority=1)
Definition: BTask.cpp:35
virtual void run()
Definition: BTask.cpp:102
BUInt ostackSize
Definition: BTask.h:36
Definition: BError.h:25
Definition: BTask.h:16
virtual ~BTask()
Definition: BTask.cpp:30