/
dispatch_task.h
62 lines (51 loc) · 1.63 KB
/
dispatch_task.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2021 XMOS LIMITED. This Software is subject to the terms of the
// XMOS Public License: Version 1
#ifndef DISPATCH_TASK_H_
#define DISPATCH_TASK_H_
#include <stdbool.h>
#include <stddef.h>
#ifdef XCORE
#define DISPATCH_TASK_FUNCTION __attribute__((fptrgroup("dispatch_function")))
#else
#define DISPATCH_TASK_FUNCTION
#endif
typedef void (*dispatch_function_t)(void *);
typedef struct dispatch_task_struct dispatch_task_t;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/** Create a new task, non-waitable task
*
* \param function Function to perform, signature must be <tt>void(void*)</tt>
* \param argument Function argument
* \param waitable The task is waitable if TRUE, otherwise the task can not
* be waited on
*
* \return Task object
*/
dispatch_task_t *dispatch_task_create(dispatch_function_t function,
void *aargumentrg, bool waitable);
/** Initialize a task
*
* \param task Task object
* \param function Function to perform, signature must be <tt>void(void*)</tt>
* \param argument Function argument
* \param waitable The task is waitable if TRUE, otherwise the task can not
* be waited on
*/
void dispatch_task_init(dispatch_task_t *task, dispatch_function_t function,
void *argument, bool waitable);
/** Run the task in the caller's thread
*
* \param task Task object
*/
void dispatch_task_perform(dispatch_task_t *task);
/** Destroy the task
*
* \param task Task object
*/
void dispatch_task_delete(dispatch_task_t *task);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // DISPATCH_TASK_H_