mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
--- a/rtos/Thread.h	Tue Dec 17 23:23:45 2019 +0000
+++ b/rtos/Thread.h	Tue Dec 31 06:02:27 2019 +0000
@@ -1,5 +1,5 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2019 ARM Limited
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -23,18 +23,21 @@
 #define THREAD_H
 
 #include <stdint.h>
-#include "cmsis_os2.h"
-#include "mbed_rtos1_types.h"
-#include "mbed_rtos_storage.h"
+#include "rtos/mbed_rtos_types.h"
+#include "rtos/mbed_rtos1_types.h"
+#include "rtos/mbed_rtos_storage.h"
 #include "platform/Callback.h"
 #include "platform/mbed_toolchain.h"
 #include "platform/NonCopyable.h"
 #include "rtos/Semaphore.h"
 #include "rtos/Mutex.h"
 
+#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
+
 namespace rtos {
-/** \addtogroup rtos */
+/** \addtogroup rtos-public-api */
 /** @{*/
+
 /**
  * \defgroup rtos_Thread Thread class
  * @{
@@ -87,8 +90,8 @@
     /** Allocate a new thread without starting execution
       @param   priority       initial priority of the thread function. (default: osPriorityNormal).
       @param   stack_size     stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
-      @param   stack_mem      pointer to the stack area to be used by this thread (default: NULL).
-      @param   name           name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: NULL)
+      @param   stack_mem      pointer to the stack area to be used by this thread (default: nullptr).
+      @param   name           name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: nullptr)
 
       @note Default value of tz_module will be MBED_TZ_DEFAULT_ACCESS
       @note You cannot call this function from ISR context.
@@ -96,7 +99,7 @@
 
     Thread(osPriority priority = osPriorityNormal,
            uint32_t stack_size = OS_STACK_SIZE,
-           unsigned char *stack_mem = NULL, const char *name = NULL)
+           unsigned char *stack_mem = nullptr, const char *name = nullptr)
     {
         constructor(priority, stack_size, stack_mem, name);
     }
@@ -108,149 +111,20 @@
                               threads not using secure calls at all. See "TrustZone RTOS Context Management" for more details.
       @param   priority       initial priority of the thread function. (default: osPriorityNormal).
       @param   stack_size     stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
-      @param   stack_mem      pointer to the stack area to be used by this thread (default: NULL).
-      @param   name           name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: NULL)
+      @param   stack_mem      pointer to the stack area to be used by this thread (default: nullptr).
+      @param   name           name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: nullptr)
 
       @note You cannot call this function from ISR context.
     */
 
     Thread(uint32_t tz_module, osPriority priority = osPriorityNormal,
            uint32_t stack_size = OS_STACK_SIZE,
-           unsigned char *stack_mem = NULL, const char *name = NULL)
+           unsigned char *stack_mem = nullptr, const char *name = nullptr)
     {
         constructor(tz_module, priority, stack_size, stack_mem, name);
     }
 
 
-    /** Create a new thread, and start it executing the specified function.
-      @param   task           function to be executed by this thread.
-      @param   priority       initial priority of the thread function. (default: osPriorityNormal).
-      @param   stack_size     stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
-      @param   stack_mem      pointer to the stack area to be used by this thread (default: NULL).
-      @deprecated
-        Thread-spawning constructors hide errors. Replaced by thread.start(task).
-
-        @code
-        Thread thread(priority, stack_size, stack_mem);
-
-        osStatus status = thread.start(task);
-        if (status != osOK) {
-            error("oh no!");
-        }
-        @endcode
-
-      @note You cannot call this function from ISR context.
-    */
-    MBED_DEPRECATED_SINCE("mbed-os-5.1",
-                          "Thread-spawning constructors hide errors. "
-                          "Replaced by thread.start(task).")
-    Thread(mbed::Callback<void()> task,
-           osPriority priority = osPriorityNormal,
-           uint32_t stack_size = OS_STACK_SIZE,
-           unsigned char *stack_mem = NULL)
-    {
-        constructor(task, priority, stack_size, stack_mem);
-    }
-
-    /** Create a new thread, and start it executing the specified function.
-      @param   argument       pointer that is passed to the thread function as start argument. (default: NULL).
-      @param   task           argument to task.
-      @param   priority       initial priority of the thread function. (default: osPriorityNormal).
-      @param   stack_size     stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
-      @param   stack_mem      pointer to the stack area to be used by this thread (default: NULL).
-      @deprecated
-        Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
-
-        @code
-        Thread thread(priority, stack_size, stack_mem);
-
-        osStatus status = thread.start(callback(task, argument));
-        if (status != osOK) {
-            error("oh no!");
-        }
-        @endcode
-
-        @note You cannot call this function from ISR context.
-    */
-    template <typename T>
-    MBED_DEPRECATED_SINCE("mbed-os-5.1",
-                          "Thread-spawning constructors hide errors. "
-                          "Replaced by thread.start(callback(task, argument)).")
-    Thread(T *argument, void (T::*task)(),
-           osPriority priority = osPriorityNormal,
-           uint32_t stack_size = OS_STACK_SIZE,
-           unsigned char *stack_mem = NULL)
-    {
-        constructor(mbed::callback(task, argument),
-                    priority, stack_size, stack_mem);
-    }
-
-    /** Create a new thread, and start it executing the specified function.
-      @param   argument       pointer that is passed to the thread function as start argument. (default: NULL).
-      @param   task           argument to task.
-      @param   priority       initial priority of the thread function. (default: osPriorityNormal).
-      @param   stack_size     stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
-      @param   stack_mem      pointer to the stack area to be used by this thread (default: NULL).
-      @deprecated
-        Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
-
-        @code
-        Thread thread(priority, stack_size, stack_mem);
-
-        osStatus status = thread.start(callback(task, argument));
-        if (status != osOK) {
-            error("oh no!");
-        }
-        @endcode
-
-      @note You cannot call this function from ISR context.
-    */
-    template <typename T>
-    MBED_DEPRECATED_SINCE("mbed-os-5.1",
-                          "Thread-spawning constructors hide errors. "
-                          "Replaced by thread.start(callback(task, argument)).")
-    Thread(T *argument, void (*task)(T *),
-           osPriority priority = osPriorityNormal,
-           uint32_t stack_size = OS_STACK_SIZE,
-           unsigned char *stack_mem = NULL)
-    {
-        constructor(mbed::callback(task, argument),
-                    priority, stack_size, stack_mem);
-    }
-
-    /** Create a new thread, and start it executing the specified function.
-        Provided for backwards compatibility
-      @param   task           function to be executed by this thread.
-      @param   argument       pointer that is passed to the thread function as start argument. (default: NULL).
-      @param   priority       initial priority of the thread function. (default: osPriorityNormal).
-      @param   stack_size     stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
-      @param   stack_mem      pointer to the stack area to be used by this thread (default: NULL).
-      @deprecated
-        Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
-
-        @code
-        Thread thread(priority, stack_size, stack_mem);
-
-        osStatus status = thread.start(callback(task, argument));
-        if (status != osOK) {
-            error("oh no!");
-        }
-        @endcode
-
-        @note You cannot call this function from ISR context.
-    */
-    MBED_DEPRECATED_SINCE("mbed-os-5.1",
-                          "Thread-spawning constructors hide errors. "
-                          "Replaced by thread.start(callback(task, argument)).")
-    Thread(void (*task)(void const *argument), void *argument = NULL,
-           osPriority priority = osPriorityNormal,
-           uint32_t stack_size = OS_STACK_SIZE,
-           unsigned char *stack_mem = NULL)
-    {
-        constructor(mbed::callback((void (*)(void *))task, argument),
-                    priority, stack_size, stack_mem);
-    }
-
     /** Starts a thread executing the specified function.
       @param   task           function to be executed by this thread.
       @return  status code that indicates the execution status of the function.
@@ -260,24 +134,6 @@
     */
     osStatus start(mbed::Callback<void()> task);
 
-    /** Starts a thread executing the specified function.
-      @param   obj            argument to task
-      @param   method         function to be executed by this thread.
-      @return  status code that indicates the execution status of the function.
-      @deprecated
-          The start function does not support cv-qualifiers. Replaced by start(callback(obj, method)).
-
-      @note You cannot call this function from ISR context.
-    */
-    template <typename T, typename M>
-    MBED_DEPRECATED_SINCE("mbed-os-5.1",
-                          "The start function does not support cv-qualifiers. "
-                          "Replaced by thread.start(callback(obj, method)).")
-    osStatus start(T *obj, M method)
-    {
-        return start(mbed::callback(obj, method));
-    }
-
     /** Wait for thread to terminate
       @return  status code that indicates the execution status of the function.
 
@@ -387,7 +243,7 @@
     uint32_t max_stack() const;
 
     /** Get thread name
-      @return  thread name or NULL if the name was not set.
+      @return  thread name or nullptr if the name was not set.
 
       @note You may call this function from ISR context.
      */
@@ -473,7 +329,7 @@
     static osStatus yield();
 
     /** Get the thread id of the current running thread.
-      @return  thread ID for reference by other functions or NULL in case of error.
+      @return  thread ID for reference by other functions or nullptr in case of error.
 
       @note You may call this function from ISR context.
       @deprecated Static methods only affecting current thread cause confusion. Replaced by ThisThread::get_id.
@@ -517,18 +373,13 @@
     // delegated constructors
     void constructor(osPriority priority = osPriorityNormal,
                      uint32_t stack_size = OS_STACK_SIZE,
-                     unsigned char *stack_mem = NULL,
-                     const char *name = NULL);
-    void constructor(mbed::Callback<void()> task,
-                     osPriority priority = osPriorityNormal,
-                     uint32_t stack_size = OS_STACK_SIZE,
-                     unsigned char *stack_mem = NULL,
-                     const char *name = NULL);
+                     unsigned char *stack_mem = nullptr,
+                     const char *name = nullptr);
     void constructor(uint32_t tz_module,
                      osPriority priority = osPriorityNormal,
                      uint32_t stack_size = OS_STACK_SIZE,
-                     unsigned char *stack_mem = NULL,
-                     const char *name = NULL);
+                     unsigned char *stack_mem = nullptr,
+                     const char *name = nullptr);
     static void _thunk(void *thread_ptr);
 
     mbed::Callback<void()>     _task;
@@ -545,4 +396,4 @@
 }
 #endif
 
-
+#endif