gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/canvas-window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'agg-plot/canvas-window.cpp')
-rw-r--r--agg-plot/canvas-window.cpp 36
1 files changed, 28 insertions, 8 deletions
diff --git a/agg-plot/canvas-window.cpp b/agg-plot/canvas-window.cpp
index ddc18fa9..60598484 100644
--- a/agg-plot/canvas-window.cpp
+++ b/agg-plot/canvas-window.cpp
@@ -62,15 +62,12 @@ bool canvas_window::start_new_thread (std::auto_ptr<canvas_window::thread_info>&
return false;
pthread_attr_t attr[1];
- pthread_t win_thread[1];
pthread_attr_init (attr);
- pthread_attr_setdetachstate (attr, PTHREAD_CREATE_DETACHED);
-
- this->status = canvas_window::starting;
+ pthread_attr_setdetachstate (attr, PTHREAD_CREATE_JOINABLE);
void *user_data = (void *) inf.get();
- if (pthread_create(win_thread, attr, canvas_thread_function, user_data))
+ if (pthread_create(&m_thread, attr, canvas_thread_function, user_data))
{
this->status = canvas_window::error;
pthread_attr_destroy (attr);
@@ -108,9 +105,32 @@ canvas_thread_function (void *_inf)
win->unlock();
- GSL_SHELL_LOCK();
- window_index_remove (inf->L, inf->window_id);
- GSL_SHELL_UNLOCK();
+ pthread_mutex_lock (gsl_shell_shutdown_mutex);
+ if (!gsl_shell_shutting_down)
+ {
+ GSL_SHELL_LOCK();
+ window_index_remove (inf->L, inf->window_id);
+ GSL_SHELL_UNLOCK();
+ }
+ pthread_mutex_unlock (gsl_shell_shutdown_mutex);
return NULL;
}
+
+void
+canvas_window::shutdown_close()
+{
+ lock();
+ if (status == canvas_window::running)
+ {
+ close_request();
+ unlock();
+ pthread_mutex_unlock (gsl_shell_shutdown_mutex);
+ pthread_join(m_thread, NULL);
+ pthread_mutex_lock (gsl_shell_shutdown_mutex);
+ }
+ else
+ {
+ unlock();
+ }
+}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月17日 15:27:59 +0000

AltStyle によって変換されたページ (->オリジナル) /