|
Reduct
v4.0.5-1-g4851deb
A functional and immutable language.
|
Data Structures | |
| struct | reduct_task_id_t |
| Task ID structure. More... | |
| struct | reduct_task_t |
| Task structure. More... | |
| struct | reduct_task_global_t |
| Global thread-related state structure. More... | |
Macros | |
| #define | REDUCT_TASK_QUEUE_MAX 256 |
| The maximum number of tasks. | |
| #define | REDUCT_TASK_SPIN_MAX 1000 |
| The maximum number of times to spin while waiting for work to be ready. | |
| #define | REDUCT_TASK_ID_INVALID ((reduct_task_id_t){ .index = UINT16_MAX, .generation = UINT16_MAX }) |
| Invalid task ID. | |
Functions | |
| REDUCT_API int | reduct_task_worker (void *arg) |
| Worker thread main loop.. | |
| REDUCT_API void | reduct_task_global_init (reduct_task_global_t *global) |
| Initialize a global task state. | |
| REDUCT_API void | reduct_task_global_deinit (reduct_task_global_t *global) |
| Deinitialize a global task state. | |
| REDUCT_API bool | reduct_task_create (struct reduct *reduct, void(*func)(struct reduct *reduct, void *arg), void *arg, reduct_task_id_t *outId) |
| Try to create a new task. | |
| REDUCT_API void | reduct_task_join (struct reduct *reduct, reduct_task_id_t id) |
| Wait for a task to finish. | |
| static REDUCT_ALWAYS_INLINE uint64_t | reduct_task_queue_size (reduct_task_global_t *global) |
| Retrieve the number of pending tasks. | |
| REDUCT_API void | reduct_task_barrier (struct reduct *reduct) |
| Barrier function to ensure all threads have either reached the barrier. | |
| #define REDUCT_TASK_QUEUE_MAX 256 |
| #define REDUCT_TASK_SPIN_MAX 1000 |
| #define REDUCT_TASK_ID_INVALID ((reduct_task_id_t){ .index = UINT16_MAX, .generation = UINT16_MAX }) |
| REDUCT_API int reduct_task_worker | ( | void * | arg | ) |
Worker thread main loop..
| arg | Pointer to the reduct_t structure of the thread. |
| REDUCT_API void reduct_task_global_init | ( | reduct_task_global_t * | global | ) |
Initialize a global task state.
| global | Pointer to the global task state to initialize. |
| REDUCT_API void reduct_task_global_deinit | ( | reduct_task_global_t * | global | ) |
Deinitialize a global task state.
| global | Pointer to the global task state to deinitialize. |
| REDUCT_API bool reduct_task_create | ( | struct reduct * | reduct, |
| void(*)(struct reduct *reduct, void *arg) | func, | ||
| void * | arg, | ||
| reduct_task_id_t * | outId | ||
| ) |
Try to create a new task.
| reduct | Pointer to the Reduct structure. |
| func | The function to execute in the task. |
| arg | The argument to pass to the function. |
| outId | Pointer to store the ID of the created task. |
true if the task was created, false if the queue is full. | REDUCT_API void reduct_task_join | ( | struct reduct * | reduct, |
| reduct_task_id_t | id | ||
| ) |
Wait for a task to finish.
| reduct | Pointer to the Reduct structure. |
| id | The id of the task to wait for. |
|
inlinestatic |
| REDUCT_API void reduct_task_barrier | ( | struct reduct * | reduct | ) |
Barrier function to ensure all threads have either reached the barrier.
Once the function returns all threads that have reached the barrier will be unblocked.
| reduct | Pointer to the Reduct structure. |