20 #ifndef ETCPAL_THREAD_H_
21 #define ETCPAL_THREAD_H_
23 #include "etcpal/error.h"
24 #include "etcpal/os_thread.h"
163 #define ETCPAL_THREAD_SET_DEFAULT_PARAMS(threadparamsptr) \
166 (threadparamsptr)->priority = ETCPAL_THREAD_DEFAULT_PRIORITY; \
167 (threadparamsptr)->stack_size = ETCPAL_THREAD_DEFAULT_STACK; \
168 (threadparamsptr)->thread_name = ETCPAL_THREAD_DEFAULT_NAME; \
169 (threadparamsptr)->platform_data = NULL; \
180 #define ETCPAL_THREAD_PARAMS_INIT_VALUES \
181 ETCPAL_THREAD_DEFAULT_PRIORITY, ETCPAL_THREAD_DEFAULT_STACK, ETCPAL_THREAD_DEFAULT_NAME, NULL
191 #define ETCPAL_THREAD_PARAMS_INIT \
193 ETCPAL_THREAD_PARAMS_INIT_VALUES \
198 void (*thread_fn)(
void*),
206 #if !defined(etcpal_thread_get_current_os_handle) || DOXYGEN
etcpal_error_t
A set of error codes that can be returned by library functions.
Definition: error.h:49
struct EtcPalThreadParams EtcPalThreadParams
A set of parameters for an etcpal_thread.
etcpal_error_t etcpal_thread_create(etcpal_thread_t *id, const EtcPalThreadParams *params, void(*thread_fn)(void *), void *thread_arg)
Create a new thread.
etcpal_error_t etcpal_thread_timed_join(etcpal_thread_t *id, int timeout_ms)
Wait for a thread to finish execution, giving up after a timeout.
PLATFORM_DEFINED etcpal_thread_t
The thread handle.
Definition: thread.dox:35
etcpal_error_t etcpal_thread_join(etcpal_thread_t *id)
Wait for a thread to finish execution.
etcpal_error_t etcpal_thread_terminate(etcpal_thread_t *id)
Forcefully kill a thread.
etcpal_error_t etcpal_thread_sleep(unsigned int sleep_ms)
Provides a platform-neutral sleep.
PLATFORM_DEFINED etcpal_thread_os_handle_t
The native OS handle type for threads on this platform.
Definition: thread.dox:42
etcpal_thread_os_handle_t etcpal_thread_get_current_os_handle(void)
Get the native OS handle of the currently executing thread.
etcpal_thread_os_handle_t etcpal_thread_get_os_handle(etcpal_thread_t *id)
Get the native OS handle of an EtcPal thread.
A set of parameters for an etcpal_thread.
Definition: thread.h:130
unsigned int priority
The priority of the thread.
Definition: thread.h:132
void * platform_data
Pointer to a platform-specific parameter structure.
Definition: thread.h:159
unsigned int stack_size
The stack size of the thread in bytes.
Definition: thread.h:141
const char * thread_name
A name for the thread, maximum length ETCPAL_THREAD_NAME_MAX_LENGTH.
Definition: thread.h:143