[qwaq] Pass resource data into the thread

Things have come crashing down, but no fire (ie, no deadlocks so far).
This commit is contained in:
Bill Currie 2020-03-21 00:14:33 +09:00
parent ac3fef6dd8
commit 7beaa567e6
3 changed files with 9 additions and 8 deletions

View file

@ -239,12 +239,14 @@ start_progs_thread (qwaq_thread_t *thread)
}
qwaq_thread_t *
create_thread (void *(*thread_func) (void *))
create_thread (void *(*thread_func) (qwaq_thread_t *), void *data)
{
qwaq_thread_t *thread = calloc (1, sizeof (*thread));
thread->data = data;
DARRAY_APPEND (&thread_data, thread);
pthread_create (&thread->thread_id, 0, thread_func, thread);
pthread_create (&thread->thread_id, 0,
(void*(*)(void*))thread_func, thread);
return thread;
}

View file

@ -1553,11 +1553,9 @@ bi_mvwblit_line (progs_t *pr)
}
static void *
qwaq_curses_thread (void *data)
qwaq_curses_thread (qwaq_thread_t *thread)
{
__auto_type thread = (qwaq_thread_t *) data;
progs_t *pr = thread->pr;
qwaq_resources_t *res = PR_Resources_Find (pr, "qwaq");
qwaq_resources_t *res = thread->data;
while (1) {
process_commands (res);
@ -1587,7 +1585,7 @@ bi_initialize (progs_t *pr)
res->stdscr.win = stdscr;
create_thread (qwaq_curses_thread);
create_thread (qwaq_curses_thread, res);
}
static void

View file

@ -10,10 +10,11 @@ typedef struct qwaq_thread_s {
sys_printf_t sys_printf;
progs_t *pr;
func_t main_func;
void *data;
} qwaq_thread_t;
void BI_Init (progs_t *pr);
extern struct cbuf_s *qwaq_cbuf;
qwaq_thread_t *create_thread (void *(*thread_func) (void *));
qwaq_thread_t *create_thread (void *(*thread_func) (qwaq_thread_t *), void *);
#endif//__qwaq_h