static void lxynth_shutdown_driver (void) { DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__); if (lxynth_root->running) { lxynth_root->running = 0; s_window_quit(lxynth_root->window); s_thread_join(lxynth_root->tid, NULL); kill_timer(lxynth_root->timerid); } while (!s_list_eol(lxynth_root->eventq->list, 0)) { s_event_t *event = s_list_get(lxynth_root->eventq->list, 0); s_list_remove(lxynth_root->eventq->list, 0); s_event_uninit(event); } s_free(lxynth_root->eventq->list); s_thread_mutex_destroy(lxynth_root->eventq->mut); s_free(lxynth_root->eventq); while (!s_list_eol(lxynth_root->gd->list, 0)) { struct graphics_device *gd = s_list_get(lxynth_root->gd->list, 0); lxynth_device_t *wd = (lxynth_device_t *) gd->driver_data; s_list_remove(lxynth_root->gd->list, 0); s_free(wd->title); s_surface_destroy(wd->surface); s_free(wd); s_free(gd); } s_free(lxynth_root->gd->list); s_thread_mutex_destroy(lxynth_root->gd->mut); s_free(lxynth_root->gd); s_free(lxynth_root); }
int s_handlers_uninit (s_window_t *window) { s_handler_t *hndl; s_thread_mutex_lock(window->handlers->mut); while (!s_list_eol(window->handlers->list, 0)) { hndl = (s_handler_t *) s_list_get(window->handlers->list, 0); s_list_remove(window->handlers->list, 0); s_handler_uninit(hndl); } s_thread_mutex_unlock(window->handlers->mut); s_thread_mutex_destroy(window->handlers->mut); s_list_uninit(window->handlers->list); s_free(window->handlers); return 0; }
int s_eventq_uninit (s_window_t *window) { s_event_t *e; s_thread_mutex_destroy(window->eventq->mut); s_thread_cond_destroy(window->eventq->cond); while (!s_list_eol(window->eventq->queue, 0)) { e = (s_event_t *) s_list_get(window->eventq->queue, 0); s_list_remove(window->eventq->queue, 0); s_event_uninit(e); } s_free(window->eventq->queue); s_free(window->eventq); return 0; }
s_thread_t * s_thread_create (void * (*f) (void *), void *farg) { s_thread_t *tid; s_thread_arg_t *arg; if ((s_thread_api == NULL) || (s_thread_api->thread_create == NULL)) { return NULL; } tid = (s_thread_t *) s_malloc(sizeof(s_thread_t)); arg = (s_thread_arg_t *) s_malloc(sizeof(s_thread_arg_t)); arg->r = &s_thread_run; arg->f = f; arg->arg = farg; s_thread_cond_init(&arg->cond); s_thread_mutex_init(&arg->mut); s_thread_mutex_lock(arg->mut); arg->flag = 0; s_thread_cond_signal(arg->cond); s_thread_mutex_unlock(arg->mut); s_thread_api->thread_create(tid, arg); s_thread_mutex_lock(arg->mut); while (arg->flag != 1) { if (s_thread_cond_wait(arg->cond, arg->mut)) { debugf(DSYS, "s_thread_cond_wait failed"); return NULL; } } s_thread_mutex_unlock(arg->mut); s_thread_cond_destroy(arg->cond); s_thread_mutex_destroy(arg->mut); s_free(arg); arg = NULL; return tid; }
int s_pollfds_uninit (s_window_t *window) { s_pollfd_t *pfd; s_thread_mutex_lock(window->pollfds->mut); while (!s_list_eol(window->pollfds->list, 0)) { pfd = (s_pollfd_t *) s_list_get(window->pollfds->list, 0); s_list_remove(window->pollfds->list, 0); if (pfd->pf_close != NULL) { pfd->pf_close(window, pfd); } s_pollfd_uninit(pfd); } s_thread_mutex_unlock(window->pollfds->mut); s_thread_mutex_destroy(window->pollfds->mut); s_list_uninit(window->pollfds->list); s_free(window->pollfds); return 0; }
/** * \brief Class destructor * * Destructor for the effect-enabled window object. Also destroys the effect * mutex. */ GuiEffectWindow::~GuiEffectWindow() { s_thread_mutex_destroy(effectMutex); }