void window::start (lua_State *L, gslshell::ret_status& st) { this->lock(); if (status != canvas_window::running) { typedef canvas_window::thread_info thread_info; std::auto_ptr<thread_info> inf(new thread_info(L, this)); this->window_id = window_index_add (L, -1); inf->window_id = this->window_id; if (! this->start_new_thread (inf)) { window_index_remove (L, this->window_id); this->unlock(); st.error("error during thread initialization", "window creation"); } } else { this->unlock(); st.error("window is already active", "window creation"); } }
void * canvas_thread_function (void *_inf) { typedef canvas_window::thread_info thread_info; std::auto_ptr<thread_info> inf((thread_info *) _inf); platform_support_ext::prepare(); canvas_window *win = inf->win; win->caption("GSL shell plot"); if (win->init(480, 480, agg::window_resize)) { win->status = canvas_window::running; int ec = win->run(); win->status = (ec == 0 ? canvas_window::closed : canvas_window::error); } else { win->status = canvas_window::error; } win->unlock(); gsl_shell_state* gs = win->state(); pthread_mutex_lock (&gs->shutdown_mutex); if (!gs->is_shutting_down) { pthread_mutex_lock(&gs->exec_mutex); window_index_remove (gs->L, inf->window_id); pthread_mutex_unlock(&gs->exec_mutex); } pthread_mutex_unlock (&gs->shutdown_mutex); return NULL; }