static void r2tox_disconnect() { r_th_kill (thread, true); //r_th_free (thread); thread = NULL; tox_kill (tox); tox = NULL; }
R_API void *r_th_kill_free(struct r_th_t *th) { if (!th) { return NULL; } r_th_kill (th, true); r_th_free (th); return NULL; }
R_API void *r_th_free(struct r_th_t *th) { r_th_kill (th, true); #if __WINDOWS__ && !defined(__CYGWIN__) CloseHandle (th->tid); #endif r_th_lock_free (th->lock); free (th); return NULL; }
static int visual_repeat_thread(RThread *th) { RCore *core = th->user; int i = 0; for (;;) { if (core->cons->breaked) break; r_core_visual_refresh (core); r_cons_flush (); r_cons_gotoxy (0, 0); r_cons_printf ("[@%d] ", i++); r_cons_flush (); r_sys_sleep (1); } r_th_kill (th, 1); return 0; }
R_API bool r_th_start(RThread *th, int enable) { bool ret = true; if (enable) { if (!th->running) { // start thread while (!th->ready) { /* spinlock */ } r_th_lock_leave (th->lock); } } else { if (th->running) { // stop thread r_th_kill (th, 0); r_th_lock_enter (th->lock); // deadlock? } } th->running = enable; return ret; }