Yes

Dependents:   Asservissement_Gyro

Committer:
braichi13
Date:
Sun May 08 14:39:47 2022 +0000
Revision:
0:77205fc699b9
Programme du Gyropode

Who changed what in which revision?

UserRevisionLine numberNew contents of line
braichi13 0:77205fc699b9 1 /* mbed Microcontroller Library
braichi13 0:77205fc699b9 2 * Copyright (c) 2006-2012 ARM Limited
braichi13 0:77205fc699b9 3 *
braichi13 0:77205fc699b9 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
braichi13 0:77205fc699b9 5 * of this software and associated documentation files (the "Software"), to deal
braichi13 0:77205fc699b9 6 * in the Software without restriction, including without limitation the rights
braichi13 0:77205fc699b9 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
braichi13 0:77205fc699b9 8 * copies of the Software, and to permit persons to whom the Software is
braichi13 0:77205fc699b9 9 * furnished to do so, subject to the following conditions:
braichi13 0:77205fc699b9 10 *
braichi13 0:77205fc699b9 11 * The above copyright notice and this permission notice shall be included in
braichi13 0:77205fc699b9 12 * all copies or substantial portions of the Software.
braichi13 0:77205fc699b9 13 *
braichi13 0:77205fc699b9 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
braichi13 0:77205fc699b9 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
braichi13 0:77205fc699b9 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
braichi13 0:77205fc699b9 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
braichi13 0:77205fc699b9 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
braichi13 0:77205fc699b9 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
braichi13 0:77205fc699b9 20 * SOFTWARE.
braichi13 0:77205fc699b9 21 */
braichi13 0:77205fc699b9 22 #ifndef THREAD_H
braichi13 0:77205fc699b9 23 #define THREAD_H
braichi13 0:77205fc699b9 24
braichi13 0:77205fc699b9 25 #include <stdint.h>
braichi13 0:77205fc699b9 26 #include "cmsis_os.h"
braichi13 0:77205fc699b9 27 #include "platform/Callback.h"
braichi13 0:77205fc699b9 28 #include "platform/toolchain.h"
braichi13 0:77205fc699b9 29 #include "rtos/Semaphore.h"
braichi13 0:77205fc699b9 30 #include "rtos/Mutex.h"
braichi13 0:77205fc699b9 31
braichi13 0:77205fc699b9 32 namespace rtos {
braichi13 0:77205fc699b9 33 /** \addtogroup rtos */
braichi13 0:77205fc699b9 34 /** @{*/
braichi13 0:77205fc699b9 35
braichi13 0:77205fc699b9 36 /** The Thread class allow defining, creating, and controlling thread functions in the system.
braichi13 0:77205fc699b9 37 *
braichi13 0:77205fc699b9 38 * Example:
braichi13 0:77205fc699b9 39 * @code
braichi13 0:77205fc699b9 40 * #include "mbed.h"
braichi13 0:77205fc699b9 41 * #include "rtos.h"
braichi13 0:77205fc699b9 42 *
braichi13 0:77205fc699b9 43 * Thread thread;
braichi13 0:77205fc699b9 44 * DigitalOut led1(LED1);
braichi13 0:77205fc699b9 45 * volatile bool running = true;
braichi13 0:77205fc699b9 46 *
braichi13 0:77205fc699b9 47 * // Blink function toggles the led in a long running loop
braichi13 0:77205fc699b9 48 * void blink(DigitalOut *led) {
braichi13 0:77205fc699b9 49 * while (running) {
braichi13 0:77205fc699b9 50 * *led = !*led;
braichi13 0:77205fc699b9 51 * Thread::wait(1000);
braichi13 0:77205fc699b9 52 * }
braichi13 0:77205fc699b9 53 * }
braichi13 0:77205fc699b9 54 *
braichi13 0:77205fc699b9 55 * // Spawns a thread to run blink for 5 seconds
braichi13 0:77205fc699b9 56 * int main() {
braichi13 0:77205fc699b9 57 * thread.start(led1, blink);
braichi13 0:77205fc699b9 58 * Thread::wait(5000);
braichi13 0:77205fc699b9 59 * running = false;
braichi13 0:77205fc699b9 60 * thread.join();
braichi13 0:77205fc699b9 61 * }
braichi13 0:77205fc699b9 62 * @endcode
braichi13 0:77205fc699b9 63 */
braichi13 0:77205fc699b9 64 class Thread {
braichi13 0:77205fc699b9 65 public:
braichi13 0:77205fc699b9 66 /** Allocate a new thread without starting execution
braichi13 0:77205fc699b9 67 @param priority initial priority of the thread function. (default: osPriorityNormal).
braichi13 0:77205fc699b9 68 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
braichi13 0:77205fc699b9 69 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
braichi13 0:77205fc699b9 70 */
braichi13 0:77205fc699b9 71 Thread(osPriority priority=osPriorityNormal,
braichi13 0:77205fc699b9 72 uint32_t stack_size=DEFAULT_STACK_SIZE,
braichi13 0:77205fc699b9 73 unsigned char *stack_pointer=NULL) {
braichi13 0:77205fc699b9 74 constructor(priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 75 }
braichi13 0:77205fc699b9 76
braichi13 0:77205fc699b9 77 /** Create a new thread, and start it executing the specified function.
braichi13 0:77205fc699b9 78 @param task function to be executed by this thread.
braichi13 0:77205fc699b9 79 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
braichi13 0:77205fc699b9 80 @param priority initial priority of the thread function. (default: osPriorityNormal).
braichi13 0:77205fc699b9 81 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
braichi13 0:77205fc699b9 82 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
braichi13 0:77205fc699b9 83 @deprecated
braichi13 0:77205fc699b9 84 Thread-spawning constructors hide errors. Replaced by thread.start(task).
braichi13 0:77205fc699b9 85
braichi13 0:77205fc699b9 86 @code
braichi13 0:77205fc699b9 87 Thread thread(priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 88
braichi13 0:77205fc699b9 89 osStatus status = thread.start(task);
braichi13 0:77205fc699b9 90 if (status != osOK) {
braichi13 0:77205fc699b9 91 error("oh no!");
braichi13 0:77205fc699b9 92 }
braichi13 0:77205fc699b9 93 @endcode
braichi13 0:77205fc699b9 94 */
braichi13 0:77205fc699b9 95 MBED_DEPRECATED_SINCE("mbed-os-5.1",
braichi13 0:77205fc699b9 96 "Thread-spawning constructors hide errors. "
braichi13 0:77205fc699b9 97 "Replaced by thread.start(task).")
braichi13 0:77205fc699b9 98 Thread(mbed::Callback<void()> task,
braichi13 0:77205fc699b9 99 osPriority priority=osPriorityNormal,
braichi13 0:77205fc699b9 100 uint32_t stack_size=DEFAULT_STACK_SIZE,
braichi13 0:77205fc699b9 101 unsigned char *stack_pointer=NULL) {
braichi13 0:77205fc699b9 102 constructor(task, priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 103 }
braichi13 0:77205fc699b9 104
braichi13 0:77205fc699b9 105 /** Create a new thread, and start it executing the specified function.
braichi13 0:77205fc699b9 106 @param obj argument to task.
braichi13 0:77205fc699b9 107 @param method function to be executed by this thread.
braichi13 0:77205fc699b9 108 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
braichi13 0:77205fc699b9 109 @param priority initial priority of the thread function. (default: osPriorityNormal).
braichi13 0:77205fc699b9 110 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
braichi13 0:77205fc699b9 111 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
braichi13 0:77205fc699b9 112 @deprecated
braichi13 0:77205fc699b9 113 Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
braichi13 0:77205fc699b9 114
braichi13 0:77205fc699b9 115 @code
braichi13 0:77205fc699b9 116 Thread thread(priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 117
braichi13 0:77205fc699b9 118 osStatus status = thread.start(callback(task, argument));
braichi13 0:77205fc699b9 119 if (status != osOK) {
braichi13 0:77205fc699b9 120 error("oh no!");
braichi13 0:77205fc699b9 121 }
braichi13 0:77205fc699b9 122 @endcode
braichi13 0:77205fc699b9 123 */
braichi13 0:77205fc699b9 124 template <typename T>
braichi13 0:77205fc699b9 125 MBED_DEPRECATED_SINCE("mbed-os-5.1",
braichi13 0:77205fc699b9 126 "Thread-spawning constructors hide errors. "
braichi13 0:77205fc699b9 127 "Replaced by thread.start(callback(task, argument)).")
braichi13 0:77205fc699b9 128 Thread(T *argument, void (T::*task)(),
braichi13 0:77205fc699b9 129 osPriority priority=osPriorityNormal,
braichi13 0:77205fc699b9 130 uint32_t stack_size=DEFAULT_STACK_SIZE,
braichi13 0:77205fc699b9 131 unsigned char *stack_pointer=NULL) {
braichi13 0:77205fc699b9 132 constructor(mbed::callback(task, argument),
braichi13 0:77205fc699b9 133 priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 134 }
braichi13 0:77205fc699b9 135
braichi13 0:77205fc699b9 136 /** Create a new thread, and start it executing the specified function.
braichi13 0:77205fc699b9 137 @param obj argument to task.
braichi13 0:77205fc699b9 138 @param method function to be executed by this thread.
braichi13 0:77205fc699b9 139 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
braichi13 0:77205fc699b9 140 @param priority initial priority of the thread function. (default: osPriorityNormal).
braichi13 0:77205fc699b9 141 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
braichi13 0:77205fc699b9 142 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
braichi13 0:77205fc699b9 143 @deprecated
braichi13 0:77205fc699b9 144 Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
braichi13 0:77205fc699b9 145
braichi13 0:77205fc699b9 146 @code
braichi13 0:77205fc699b9 147 Thread thread(priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 148
braichi13 0:77205fc699b9 149 osStatus status = thread.start(callback(task, argument));
braichi13 0:77205fc699b9 150 if (status != osOK) {
braichi13 0:77205fc699b9 151 error("oh no!");
braichi13 0:77205fc699b9 152 }
braichi13 0:77205fc699b9 153 @endcode
braichi13 0:77205fc699b9 154 */
braichi13 0:77205fc699b9 155 template <typename T>
braichi13 0:77205fc699b9 156 MBED_DEPRECATED_SINCE("mbed-os-5.1",
braichi13 0:77205fc699b9 157 "Thread-spawning constructors hide errors. "
braichi13 0:77205fc699b9 158 "Replaced by thread.start(callback(task, argument)).")
braichi13 0:77205fc699b9 159 Thread(T *argument, void (*task)(T *),
braichi13 0:77205fc699b9 160 osPriority priority=osPriorityNormal,
braichi13 0:77205fc699b9 161 uint32_t stack_size=DEFAULT_STACK_SIZE,
braichi13 0:77205fc699b9 162 unsigned char *stack_pointer=NULL) {
braichi13 0:77205fc699b9 163 constructor(mbed::callback(task, argument),
braichi13 0:77205fc699b9 164 priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 165 }
braichi13 0:77205fc699b9 166
braichi13 0:77205fc699b9 167 /** Create a new thread, and start it executing the specified function.
braichi13 0:77205fc699b9 168 Provided for backwards compatibility
braichi13 0:77205fc699b9 169 @param task function to be executed by this thread.
braichi13 0:77205fc699b9 170 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
braichi13 0:77205fc699b9 171 @param priority initial priority of the thread function. (default: osPriorityNormal).
braichi13 0:77205fc699b9 172 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
braichi13 0:77205fc699b9 173 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
braichi13 0:77205fc699b9 174 @deprecated
braichi13 0:77205fc699b9 175 Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
braichi13 0:77205fc699b9 176
braichi13 0:77205fc699b9 177 @code
braichi13 0:77205fc699b9 178 Thread thread(priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 179
braichi13 0:77205fc699b9 180 osStatus status = thread.start(callback(task, argument));
braichi13 0:77205fc699b9 181 if (status != osOK) {
braichi13 0:77205fc699b9 182 error("oh no!");
braichi13 0:77205fc699b9 183 }
braichi13 0:77205fc699b9 184 @endcode
braichi13 0:77205fc699b9 185 */
braichi13 0:77205fc699b9 186 MBED_DEPRECATED_SINCE("mbed-os-5.1",
braichi13 0:77205fc699b9 187 "Thread-spawning constructors hide errors. "
braichi13 0:77205fc699b9 188 "Replaced by thread.start(callback(task, argument)).")
braichi13 0:77205fc699b9 189 Thread(void (*task)(void const *argument), void *argument=NULL,
braichi13 0:77205fc699b9 190 osPriority priority=osPriorityNormal,
braichi13 0:77205fc699b9 191 uint32_t stack_size=DEFAULT_STACK_SIZE,
braichi13 0:77205fc699b9 192 unsigned char *stack_pointer=NULL) {
braichi13 0:77205fc699b9 193 constructor(mbed::callback((void (*)(void *))task, argument),
braichi13 0:77205fc699b9 194 priority, stack_size, stack_pointer);
braichi13 0:77205fc699b9 195 }
braichi13 0:77205fc699b9 196
braichi13 0:77205fc699b9 197 /** Starts a thread executing the specified function.
braichi13 0:77205fc699b9 198 @param task function to be executed by this thread.
braichi13 0:77205fc699b9 199 @return status code that indicates the execution status of the function.
braichi13 0:77205fc699b9 200 */
braichi13 0:77205fc699b9 201 osStatus start(mbed::Callback<void()> task);
braichi13 0:77205fc699b9 202
braichi13 0:77205fc699b9 203 /** Starts a thread executing the specified function.
braichi13 0:77205fc699b9 204 @param obj argument to task
braichi13 0:77205fc699b9 205 @param method function to be executed by this thread.
braichi13 0:77205fc699b9 206 @return status code that indicates the execution status of the function.
braichi13 0:77205fc699b9 207 @deprecated
braichi13 0:77205fc699b9 208 The start function does not support cv-qualifiers. Replaced by start(callback(obj, method)).
braichi13 0:77205fc699b9 209 */
braichi13 0:77205fc699b9 210 template <typename T, typename M>
braichi13 0:77205fc699b9 211 MBED_DEPRECATED_SINCE("mbed-os-5.1",
braichi13 0:77205fc699b9 212 "The start function does not support cv-qualifiers. "
braichi13 0:77205fc699b9 213 "Replaced by thread.start(callback(obj, method)).")
braichi13 0:77205fc699b9 214 osStatus start(T *obj, M method) {
braichi13 0:77205fc699b9 215 return start(mbed::callback(obj, method));
braichi13 0:77205fc699b9 216 }
braichi13 0:77205fc699b9 217
braichi13 0:77205fc699b9 218 /** Wait for thread to terminate
braichi13 0:77205fc699b9 219 @return status code that indicates the execution status of the function.
braichi13 0:77205fc699b9 220 @note not callable from interrupt
braichi13 0:77205fc699b9 221 */
braichi13 0:77205fc699b9 222 osStatus join();
braichi13 0:77205fc699b9 223
braichi13 0:77205fc699b9 224 /** Terminate execution of a thread and remove it from Active Threads
braichi13 0:77205fc699b9 225 @return status code that indicates the execution status of the function.
braichi13 0:77205fc699b9 226 */
braichi13 0:77205fc699b9 227 osStatus terminate();
braichi13 0:77205fc699b9 228
braichi13 0:77205fc699b9 229 /** Set priority of an active thread
braichi13 0:77205fc699b9 230 @param priority new priority value for the thread function.
braichi13 0:77205fc699b9 231 @return status code that indicates the execution status of the function.
braichi13 0:77205fc699b9 232 */
braichi13 0:77205fc699b9 233 osStatus set_priority(osPriority priority);
braichi13 0:77205fc699b9 234
braichi13 0:77205fc699b9 235 /** Get priority of an active thread
braichi13 0:77205fc699b9 236 @return current priority value of the thread function.
braichi13 0:77205fc699b9 237 */
braichi13 0:77205fc699b9 238 osPriority get_priority();
braichi13 0:77205fc699b9 239
braichi13 0:77205fc699b9 240 /** Set the specified Signal Flags of an active thread.
braichi13 0:77205fc699b9 241 @param signals specifies the signal flags of the thread that should be set.
braichi13 0:77205fc699b9 242 @return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
braichi13 0:77205fc699b9 243 */
braichi13 0:77205fc699b9 244 int32_t signal_set(int32_t signals);
braichi13 0:77205fc699b9 245
braichi13 0:77205fc699b9 246 /** Clears the specified Signal Flags of an active thread.
braichi13 0:77205fc699b9 247 @param signals specifies the signal flags of the thread that should be cleared.
braichi13 0:77205fc699b9 248 @return resultant signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
braichi13 0:77205fc699b9 249 */
braichi13 0:77205fc699b9 250 int32_t signal_clr(int32_t signals);
braichi13 0:77205fc699b9 251
braichi13 0:77205fc699b9 252 /** State of the Thread */
braichi13 0:77205fc699b9 253 enum State {
braichi13 0:77205fc699b9 254 Inactive, /**< Not created or terminated */
braichi13 0:77205fc699b9 255 Ready, /**< Ready to run */
braichi13 0:77205fc699b9 256 Running, /**< Running */
braichi13 0:77205fc699b9 257 WaitingDelay, /**< Waiting for a delay to occur */
braichi13 0:77205fc699b9 258 WaitingInterval, /**< Waiting for an interval to occur */
braichi13 0:77205fc699b9 259 WaitingOr, /**< Waiting for one event in a set to occur */
braichi13 0:77205fc699b9 260 WaitingAnd, /**< Waiting for multiple events in a set to occur */
braichi13 0:77205fc699b9 261 WaitingSemaphore, /**< Waiting for a semaphore event to occur */
braichi13 0:77205fc699b9 262 WaitingMailbox, /**< Waiting for a mailbox event to occur */
braichi13 0:77205fc699b9 263 WaitingMutex, /**< Waiting for a mutex event to occur */
braichi13 0:77205fc699b9 264
braichi13 0:77205fc699b9 265 /* Not in sync with RTX below here */
braichi13 0:77205fc699b9 266 Deleted, /**< The task has been deleted */
braichi13 0:77205fc699b9 267 };
braichi13 0:77205fc699b9 268
braichi13 0:77205fc699b9 269 /** State of this Thread
braichi13 0:77205fc699b9 270 @return the State of this Thread
braichi13 0:77205fc699b9 271 */
braichi13 0:77205fc699b9 272 State get_state();
braichi13 0:77205fc699b9 273
braichi13 0:77205fc699b9 274 /** Get the total stack memory size for this Thread
braichi13 0:77205fc699b9 275 @return the total stack memory size in bytes
braichi13 0:77205fc699b9 276 */
braichi13 0:77205fc699b9 277 uint32_t stack_size();
braichi13 0:77205fc699b9 278
braichi13 0:77205fc699b9 279 /** Get the currently unused stack memory for this Thread
braichi13 0:77205fc699b9 280 @return the currently unused stack memory in bytes
braichi13 0:77205fc699b9 281 */
braichi13 0:77205fc699b9 282 uint32_t free_stack();
braichi13 0:77205fc699b9 283
braichi13 0:77205fc699b9 284 /** Get the currently used stack memory for this Thread
braichi13 0:77205fc699b9 285 @return the currently used stack memory in bytes
braichi13 0:77205fc699b9 286 */
braichi13 0:77205fc699b9 287 uint32_t used_stack();
braichi13 0:77205fc699b9 288
braichi13 0:77205fc699b9 289 /** Get the maximum stack memory usage to date for this Thread
braichi13 0:77205fc699b9 290 @return the maximum stack memory usage to date in bytes
braichi13 0:77205fc699b9 291 */
braichi13 0:77205fc699b9 292 uint32_t max_stack();
braichi13 0:77205fc699b9 293
braichi13 0:77205fc699b9 294 /** Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
braichi13 0:77205fc699b9 295 @param signals wait until all specified signal flags set or 0 for any single signal flag.
braichi13 0:77205fc699b9 296 @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
braichi13 0:77205fc699b9 297 @return event flag information or error code.
braichi13 0:77205fc699b9 298 @note not callable from interrupt
braichi13 0:77205fc699b9 299 */
braichi13 0:77205fc699b9 300 static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever);
braichi13 0:77205fc699b9 301
braichi13 0:77205fc699b9 302 /** Wait for a specified time period in millisec:
braichi13 0:77205fc699b9 303 @param millisec time delay value
braichi13 0:77205fc699b9 304 @return status code that indicates the execution status of the function.
braichi13 0:77205fc699b9 305 @note not callable from interrupt
braichi13 0:77205fc699b9 306 */
braichi13 0:77205fc699b9 307 static osStatus wait(uint32_t millisec);
braichi13 0:77205fc699b9 308
braichi13 0:77205fc699b9 309 /** Pass control to next thread that is in state READY.
braichi13 0:77205fc699b9 310 @return status code that indicates the execution status of the function.
braichi13 0:77205fc699b9 311 @note not callable from interrupt
braichi13 0:77205fc699b9 312 */
braichi13 0:77205fc699b9 313 static osStatus yield();
braichi13 0:77205fc699b9 314
braichi13 0:77205fc699b9 315 /** Get the thread id of the current running thread.
braichi13 0:77205fc699b9 316 @return thread ID for reference by other functions or NULL in case of error.
braichi13 0:77205fc699b9 317 */
braichi13 0:77205fc699b9 318 static osThreadId gettid();
braichi13 0:77205fc699b9 319
braichi13 0:77205fc699b9 320 /** Attach a function to be called by the RTOS idle task
braichi13 0:77205fc699b9 321 @param fptr pointer to the function to be called
braichi13 0:77205fc699b9 322 */
braichi13 0:77205fc699b9 323 static void attach_idle_hook(void (*fptr)(void));
braichi13 0:77205fc699b9 324
braichi13 0:77205fc699b9 325 /** Attach a function to be called when a task is killed
braichi13 0:77205fc699b9 326 @param fptr pointer to the function to be called
braichi13 0:77205fc699b9 327 */
braichi13 0:77205fc699b9 328 static void attach_terminate_hook(void (*fptr)(osThreadId id));
braichi13 0:77205fc699b9 329
braichi13 0:77205fc699b9 330 virtual ~Thread();
braichi13 0:77205fc699b9 331
braichi13 0:77205fc699b9 332 private:
braichi13 0:77205fc699b9 333 // Required to share definitions without
braichi13 0:77205fc699b9 334 // delegated constructors
braichi13 0:77205fc699b9 335 void constructor(osPriority priority=osPriorityNormal,
braichi13 0:77205fc699b9 336 uint32_t stack_size=DEFAULT_STACK_SIZE,
braichi13 0:77205fc699b9 337 unsigned char *stack_pointer=NULL);
braichi13 0:77205fc699b9 338 void constructor(mbed::Callback<void()> task,
braichi13 0:77205fc699b9 339 osPriority priority=osPriorityNormal,
braichi13 0:77205fc699b9 340 uint32_t stack_size=DEFAULT_STACK_SIZE,
braichi13 0:77205fc699b9 341 unsigned char *stack_pointer=NULL);
braichi13 0:77205fc699b9 342 static void _thunk(const void * thread_ptr);
braichi13 0:77205fc699b9 343
braichi13 0:77205fc699b9 344 mbed::Callback<void()> _task;
braichi13 0:77205fc699b9 345 osThreadId _tid;
braichi13 0:77205fc699b9 346 osThreadDef_t _thread_def;
braichi13 0:77205fc699b9 347 bool _dynamic_stack;
braichi13 0:77205fc699b9 348 Semaphore _join_sem;
braichi13 0:77205fc699b9 349 Mutex _mutex;
braichi13 0:77205fc699b9 350 };
braichi13 0:77205fc699b9 351
braichi13 0:77205fc699b9 352 }
braichi13 0:77205fc699b9 353 #endif
braichi13 0:77205fc699b9 354
braichi13 0:77205fc699b9 355 /** @}*/