36 #ifndef __embedded_rpc__thread__ 37 #define __embedded_rpc__thread__ 39 #include "erpc_config_internal.h" 45 #if ERPC_THREADS_IS(PTHREADS) 47 #elif ERPC_THREADS_IS(FREERTOS) 51 #elif ERPC_THREADS_IS(ZEPHYR) 53 #endif // ERPC_THREADS_IS 74 #if defined(__cplusplus) 96 Thread(
const char *name = 0);
108 Thread(
thread_entry_t entry, uint32_t priority = 0, uint32_t stackSize = 0,
const char *name = 0);
120 void setName(
const char *name) { m_name = name; }
127 const char *
getName(
void)
const {
return m_name; }
143 void start(
void *arg = 0);
150 static void sleep(uint32_t usecs);
159 #if ERPC_THREADS_IS(PTHREADS) 160 return reinterpret_cast<thread_id_t
>(m_thread);
161 #elif ERPC_THREADS_IS(FREERTOS) 162 return reinterpret_cast<thread_id_t
>(m_task);
163 #elif ERPC_THREADS_IS(ZEPHYR) 164 return reinterpret_cast<thread_id_t
>(m_thread);
175 #if ERPC_THREADS_IS(PTHREADS) 176 return reinterpret_cast<thread_id_t
>(pthread_self());
177 #elif ERPC_THREADS_IS(FREERTOS) 178 return reinterpret_cast<thread_id_t
>(xTaskGetCurrentTaskHandle());
179 #elif ERPC_THREADS_IS(ZEPHYR) 180 return reinterpret_cast<thread_id_t
>(k_current_get());
184 #if ERPC_THREADS_IS(ZEPHYR) 190 void setStackPointer(k_thread_stack_t *stack) { m_stack = stack; }
220 uint32_t m_stackSize;
222 #if ERPC_THREADS_IS(PTHREADS) 223 static pthread_key_t s_threadObjectKey;
225 #elif ERPC_THREADS_IS(FREERTOS) 229 #elif ERPC_THREADS_IS(ZEPHYR) 230 struct k_thread m_thread;
231 k_thread_stack_t *m_stack;
234 #if ERPC_THREADS_IS(PTHREADS) 241 static void *threadEntryPointStub(
void *arg);
242 #elif ERPC_THREADS_IS(FREERTOS) 249 static void threadEntryPointStub(
void *arg);
250 #elif ERPC_THREADS_IS(ZEPHYR) 259 static void *threadEntryPointStub(
void *arg1,
void *arg2,
void *arg3);
347 #if ERPC_THREADS_IS(PTHREADS) 353 pthread_mutex_t *getPtr(
void) {
return &m_mutex; }
357 #if ERPC_THREADS_IS(PTHREADS) 358 pthread_mutex_t m_mutex;
359 #elif ERPC_THREADS_IS(FREERTOS) 360 SemaphoreHandle_t m_mutex;
361 #elif ERPC_THREADS_IS(ZEPHYR) 362 struct k_mutex m_mutex;
391 static const uint32_t kWaitForever = 0xffffffff;
410 #if ERPC_THREADS_IS(FREERTOS) 414 void putFromISR(
void);
415 #endif // ERPC_HAS_FREERTOS 425 bool get(uint32_t timeout = kWaitForever);
432 int getCount(
void)
const;
435 #if ERPC_THREADS_IS(PTHREADS) 437 pthread_cond_t m_cond;
440 #elif ERPC_THREADS_IS(FREERTOS) 441 SemaphoreHandle_t m_sem;
442 #elif ERPC_THREADS_IS(ZEPHYR) 463 #endif // defined(__cplusplus) 467 #endif // ERPC_THREADS 469 #endif // defined(__embedded_rpc__thread__) bool operator==(Thread &o)
Compare operator compares two threads.
Definition: erpc_threading_pthreads.cpp:98
void init(thread_entry_t entry, uint32_t priority=0, uint32_t stackSize=0)
This function initializes thread.
Definition: erpc_threading_pthreads.cpp:78
void(* thread_entry_t)(void *arg)
Thread function type.
Definition: erpc_threading.h:68
static thread_id_t getCurrentThreadId(void)
This function returns thread id where function is called.
Definition: erpc_threading.h:173
Simple thread class.
Definition: erpc_threading.h:82
~Guard(void)
Destructor.
Definition: erpc_threading.h:307
static void sleep(uint32_t usecs)
This function puts thread to sleep.
Definition: erpc_threading_pthreads.cpp:109
void setName(const char *name)
This function sets name for thread.
Definition: erpc_threading.h:120
const char * getName(void) const
This function returns name of thread.
Definition: erpc_threading.h:127
virtual ~Thread(void)
Destructor.
Definition: erpc_threading_pthreads.cpp:76
Definition: erpc_arbitrated_client_manager.h:51
Definition: erpc_threading.h:291
void * thread_id_t
Unique identifier for a thread.
Definition: erpc_threading.h:86
virtual void threadEntryPoint(void)
This function execute entry function.
Definition: erpc_threading_pthreads.cpp:128
static Thread * getCurrentThread(void)
This function returns Thread instance where functions is called.
Definition: erpc_threading_pthreads.cpp:103
thread_id_t getThreadId(void) const
This function returns current thread id.
Definition: erpc_threading.h:157
void start(void *arg=0)
This function starts thread execution.
Definition: erpc_threading_pthreads.cpp:85
Guard(Mutex &mutex)
Constructor.
Definition: erpc_threading.h:299
Mutex.
Definition: erpc_threading.h:285
Simple semaphore class.
Definition: erpc_threading.h:385
Thread(const char *name=0)
Default constructor for use with the init() method.
Definition: erpc_threading_pthreads.cpp:56