Arduino STK 4.6.2
Thread.h
1
2#ifndef STK_THREAD_H
3#define STK_THREAD_H
4
5#include "Stk.h"
6#include "ArdConfig.h"
7
8#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
9
10 #include <pthread.h>
11 #define THREAD_TYPE
12 typedef pthread_t THREAD_HANDLE;
13 typedef void * THREAD_RETURN;
14 typedef void * (*THREAD_FUNCTION)(void *);
15
16
17#elif defined(__OS_WINDOWS__)
18
19 #include <windows.h>
20 #include <process.h>
21 #define THREAD_TYPE __stdcall
22 typedef unsigned long THREAD_HANDLE;
23 typedef unsigned THREAD_RETURN;
24 typedef unsigned (__stdcall *THREAD_FUNCTION)(void *);
25
26#elif defined(__RTOS__)
27 #include "freertos/FreeRTOS.h"
28 #include "freertos/task.h"
29 #define THREAD_TYPE
30 typedef TaskHandle_t THREAD_HANDLE;
31 typedef void THREAD_RETURN;
32 typedef void (*THREAD_FUNCTION)(void *);
33
34#endif
35
36/***************************************************/
56/***************************************************/
57
58#ifdef THREAD_TYPE
59
60namespace stk {
61
62class Thread : public Stk
63{
64 public:
67
70
72
77 bool start( THREAD_FUNCTION routine, void * ptr = NULL );
78
80
87 bool cancel(void);
88
90
93 bool wait(void);
94
96
101 void testCancel(void);
102
103 protected:
104
105 THREAD_HANDLE thread_;
106
107};
108
109} // stk namespace
110
111#endif
112#endif
Stk(void)
Default constructor.
void testCancel(void)
Create a cancellation point within a thread routine.
Thread()
Default constructor.
bool cancel(void)
Signal cancellation of a thread routine, returning true on success.
bool start(THREAD_FUNCTION routine, void *ptr=NULL)
Begin execution of the thread routine. Upon success, true is returned.
bool wait(void)
Block the calling routine indefinitely until the thread terminates.
~Thread()
The class destructor does not attempt to cancel or join a thread.
The STK namespace.
Definition ADSR.h:8