summaryrefslogtreecommitdiff
path: root/lib/thread.h
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-07-06 12:55:03 -0400
committerMark Stapp <mjs@voltanet.io>2020-10-23 08:59:34 -0400
commitb3d6bc6ef0140a194b4bc2993a6aba72ab5d54c9 (patch)
treeb5ef6dcab41d9da516a6ff044056e0faca7b35da /lib/thread.h
parent90a65457d12d8d90bf47eab1a4bb5446b3810d96 (diff)
* : update signature of thread_cancel api
Change thread_cancel to take a ** to an event, NULL-check before dereferencing, and NULL the caller's pointer. Update many callers to use the new signature. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/thread.h')
-rw-r--r--lib/thread.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/thread.h b/lib/thread.h
index c22b2105cd..a581796d30 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -89,6 +89,8 @@ struct thread_master {
pthread_t owner;
};
+typedef struct thread_master event_master;
+
/* Thread itself. */
struct thread {
uint8_t type; /* thread type */
@@ -147,17 +149,10 @@ struct cpu_thread_history {
#define THREAD_FD(X) ((X)->u.fd)
#define THREAD_VAL(X) ((X)->u.val)
-#define THREAD_OFF(thread) \
- do { \
- if (thread) { \
- thread_cancel(thread); \
- thread = NULL; \
- } \
- } while (0)
-
-#define THREAD_READ_OFF(thread) THREAD_OFF(thread)
-#define THREAD_WRITE_OFF(thread) THREAD_OFF(thread)
-#define THREAD_TIMER_OFF(thread) THREAD_OFF(thread)
+#define THREAD_OFF(thread) thread_cancel(&(thread))
+#define THREAD_READ_OFF(thread) thread_cancel(&(thread))
+#define THREAD_WRITE_OFF(thread) thread_cancel(&(thread))
+#define THREAD_TIMER_OFF(thread) thread_cancel(&(thread))
#define debugargdef const char *funcname, const char *schedfrom, int fromln
@@ -207,7 +202,7 @@ extern void funcname_thread_execute(struct thread_master *,
debugargdef);
#undef debugargdef
-extern void thread_cancel(struct thread *);
+extern void thread_cancel(struct thread **event);
extern void thread_cancel_async(struct thread_master *, struct thread **,
void *);
extern void thread_cancel_event(struct thread_master *, void *);