10 #ifndef __embedded_rpc__thread__ 11 #define __embedded_rpc__thread__ 13 #include "erpc_config_internal.h" 19 #if ERPC_THREADS_IS(PTHREADS) 21 #elif ERPC_THREADS_IS(FREERTOS) 25 #elif ERPC_THREADS_IS(ZEPHYR) 27 #endif // ERPC_THREADS_IS 48 #if defined(__cplusplus) 70 Thread(
const char *name = 0);
82 Thread(
thread_entry_t entry, uint32_t priority = 0, uint32_t stackSize = 0,
const char *name = 0);
94 void setName(
const char *name) { m_name = name; }
101 const char *
getName(
void)
const {
return m_name; }
117 void start(
void *arg = 0);
124 static void sleep(uint32_t usecs);
133 #if ERPC_THREADS_IS(PTHREADS) 134 return reinterpret_cast<thread_id_t
>(m_thread);
135 #elif ERPC_THREADS_IS(FREERTOS) 136 return reinterpret_cast<thread_id_t
>(m_task);
137 #elif ERPC_THREADS_IS(ZEPHYR) 138 return reinterpret_cast<thread_id_t
>(m_thread);
149 #if ERPC_THREADS_IS(PTHREADS) 150 return reinterpret_cast<thread_id_t
>(pthread_self());
151 #elif ERPC_THREADS_IS(FREERTOS) 152 return reinterpret_cast<thread_id_t
>(xTaskGetCurrentTaskHandle());
153 #elif ERPC_THREADS_IS(ZEPHYR) 154 return reinterpret_cast<thread_id_t
>(k_current_get());
158 #if ERPC_THREADS_IS(ZEPHYR) 164 void setStackPointer(k_thread_stack_t *stack) { m_stack = stack; }
194 uint32_t m_stackSize;
196 #if ERPC_THREADS_IS(PTHREADS) 197 static pthread_key_t s_threadObjectKey;
199 #elif ERPC_THREADS_IS(FREERTOS) 203 #elif ERPC_THREADS_IS(ZEPHYR) 204 struct k_thread m_thread;
205 k_thread_stack_t *m_stack;
208 #if ERPC_THREADS_IS(PTHREADS) 215 static void *threadEntryPointStub(
void *arg);
216 #elif ERPC_THREADS_IS(FREERTOS) 223 static void threadEntryPointStub(
void *arg);
224 #elif ERPC_THREADS_IS(ZEPHYR) 233 static void *threadEntryPointStub(
void *arg1,
void *arg2,
void *arg3);
321 #if ERPC_THREADS_IS(PTHREADS) 327 pthread_mutex_t *getPtr(
void) {
return &m_mutex; }
331 #if ERPC_THREADS_IS(PTHREADS) 332 pthread_mutex_t m_mutex;
333 #elif ERPC_THREADS_IS(FREERTOS) 334 SemaphoreHandle_t m_mutex;
335 #elif ERPC_THREADS_IS(ZEPHYR) 336 struct k_mutex m_mutex;
365 static const uint32_t kWaitForever = 0xffffffff;
384 #if ERPC_THREADS_IS(FREERTOS) 388 void putFromISR(
void);
389 #endif // ERPC_HAS_FREERTOS 399 bool get(uint32_t timeout = kWaitForever);
406 int getCount(
void)
const;
409 #if ERPC_THREADS_IS(PTHREADS) 411 pthread_cond_t m_cond;
414 #elif ERPC_THREADS_IS(FREERTOS) 415 SemaphoreHandle_t m_sem;
416 #elif ERPC_THREADS_IS(ZEPHYR) 437 #endif // defined(__cplusplus) 441 #endif // ERPC_THREADS 443 #endif // defined(__embedded_rpc__thread__) bool operator==(Thread &o)
Compare operator compares two threads.
Definition: erpc_threading_pthreads.cpp:72
void init(thread_entry_t entry, uint32_t priority=0, uint32_t stackSize=0)
This function initializes thread.
Definition: erpc_threading_pthreads.cpp:52
void(* thread_entry_t)(void *arg)
Thread function type.
Definition: erpc_threading.h:42
static thread_id_t getCurrentThreadId(void)
This function returns thread id where function is called.
Definition: erpc_threading.h:147
Simple thread class.
Definition: erpc_threading.h:56
~Guard(void)
Destructor.
Definition: erpc_threading.h:281
static void sleep(uint32_t usecs)
This function puts thread to sleep.
Definition: erpc_threading_pthreads.cpp:83
void setName(const char *name)
This function sets name for thread.
Definition: erpc_threading.h:94
const char * getName(void) const
This function returns name of thread.
Definition: erpc_threading.h:101
virtual ~Thread(void)
Destructor.
Definition: erpc_threading_pthreads.cpp:50
Definition: erpc_arbitrated_client_manager.h:25
Definition: erpc_threading.h:265
void * thread_id_t
Unique identifier for a thread.
Definition: erpc_threading.h:60
virtual void threadEntryPoint(void)
This function execute entry function.
Definition: erpc_threading_pthreads.cpp:102
static Thread * getCurrentThread(void)
This function returns Thread instance where functions is called.
Definition: erpc_threading_pthreads.cpp:77
thread_id_t getThreadId(void) const
This function returns current thread id.
Definition: erpc_threading.h:131
void start(void *arg=0)
This function starts thread execution.
Definition: erpc_threading_pthreads.cpp:59
Guard(Mutex &mutex)
Constructor.
Definition: erpc_threading.h:273
Mutex.
Definition: erpc_threading.h:259
Simple semaphore class.
Definition: erpc_threading.h:359
Thread(const char *name=0)
Default constructor for use with the init() method.
Definition: erpc_threading_pthreads.cpp:30