lwpa
0.1.0
LightWeight Platform Abstraction (lwpa)
|
View other versions:
|
Platform-neutral threads.
#include "lwpa_thread.h"
Data Structures | |
struct | LwpaThreadParams |
A set of parameters for an lwpa_thread. More... | |
Macros | |
#define | LWPA_THREAD_DEFAULT_PRIORITY |
The platform-specific default priority for an lwpa_thread. More... | |
#define | LWPA_THREAD_DEFAULT_STACK |
The plaform-specific default stack size for an lwpa_thread. More... | |
#define | LWPA_THREAD_DEFAULT_NAME |
The default name for an lwpa_thread. | |
#define | LWPA_THREAD_NAME_MAX_LENGTH |
The maximum length of an lwpa_thread name C-string. | |
Typedefs | |
typedef struct LwpaThreadParams | LwpaThreadParams |
A set of parameters for an lwpa_thread. | |
typedef UNDEFINED | lwpa_thread_t |
The thread identifier. More... | |
Functions | |
bool | lwpa_thread_create (lwpa_thread_t *id, const LwpaThreadParams *params, void(*thread_fn)(void *), void *thread_arg) |
Create a new thread. More... | |
bool | lwpa_thread_stop (lwpa_thread_t *id, int wait_ms) |
Stop a thread. More... | |
void | lwpa_thread_sleep (int sleep_ms) |
Provides a platform-neutral sleep. More... | |
#define LWPA_THREAD_DEFAULT_PRIORITY |
The platform-specific default priority for an lwpa_thread.
Note that thread priority is not valid on all platforms.
#define LWPA_THREAD_DEFAULT_STACK |
The plaform-specific default stack size for an lwpa_thread.
Note that thread stack size is not valid on all platforms.
typedef UNDEFINED lwpa_thread_t |
The thread identifier.
Depending on the platform, this could be a scalar type or a struct.
bool lwpa_thread_create | ( | lwpa_thread_t * | id, |
const LwpaThreadParams * | params, | ||
void(*)(void *) | thread_fn, | ||
void * | thread_arg | ||
) |
Create a new thread.
If your application has exit/shutdown behavior (i.e. it is a non-embedded application), it's good practice to always pair this with a call to lwpa_thread_stop() on exit. On some platforms, extra signaling resources are allocated when the thread is created that are not deallocated unless lwpa_thread_stop() is called.
[out] | id | Identifier for the thread that was created. |
[in] | params | Thread parameters for the thread to create |
[in] | thread_fn | Pointer to function that should be called from the new thread. This function takes one void* argument and returns void. |
[in] | thread_arg | Argument to the function called from the new thread. |
void lwpa_thread_sleep | ( | int | sleep_ms | ) |
Provides a platform-neutral sleep.
[in] | sleep_ms | How long to sleep, in milliseconds. |
bool lwpa_thread_stop | ( | lwpa_thread_t * | id, |
int | wait_ms | ||
) |
Stop a thread.
On some platforms, wait_ms is ignored and you always wait forever for a thread to stop.
[in] | id | Identifier for the thread to stop. |
[in] | wait_ms | How long to wait for the thread to stop, in milliseconds (use LWPA_WAIT_FOREVER to wait indefinitely). |