This change allows a thread's reactor loop to manage additional
file descriptors, e.g. sockets and queues, entirely within that
thread's context.
#define THREAD_NAME_MAX 16
+typedef struct reactor_t reactor_t;
typedef struct thread_t thread_t;
typedef void (*thread_fn)(void *context);
// |thread| may not be NULL.
void thread_stop(thread_t *thread);
+// Returns a reactor owned by this thread. The reactor must not be freed by the
+// caller. The returned reactor will not be NULL. |thread| may not be NULL.
+reactor_t *thread_get_reactor(const thread_t *thread);
+
// Returns the name of the given |thread|. |thread| may not be NULL.
const char *thread_name(const thread_t *thread);
reactor_stop(thread->reactor);
}
+reactor_t *thread_get_reactor(const thread_t *thread) {
+ assert(thread != NULL);
+ return thread->reactor;
+}
+
const char *thread_name(const thread_t *thread) {
assert(thread != NULL);
return thread->name;