From 811b2719ed6f5496f0af49e33f04b4743da3198c Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 1 Oct 2002 16:59:23 +0000 Subject: [PATCH] Use the deal.II features to create threads. git-svn-id: https://svn.dealii.org/trunk@6577 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/contrib/hsl/source/detached_ma27.cc | 22 ++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/deal.II/contrib/hsl/source/detached_ma27.cc b/deal.II/contrib/hsl/source/detached_ma27.cc index 0a000e5051..0294d883a0 100644 --- a/deal.II/contrib/hsl/source/detached_ma27.cc +++ b/deal.II/contrib/hsl/source/detached_ma27.cc @@ -12,6 +12,7 @@ //---------------------------- detached_ma27.cc --------------------------- #include +#include #include #include @@ -133,7 +134,7 @@ void die (const std::string &text, const T1 t1, const T2 t2) * about the parent process, so it is apparently gone */ extern "C" -void * monitor_thread (void *) +void monitor_parent_liveness () { #ifdef HAVE_STD_STRINGSTREAM std::ostringstream s; @@ -225,8 +226,10 @@ int main () get (&master_pid, 1, "master_pid"); // ...and start off a thread that // actually checks that - pthread_t monitor_thread_id; - pthread_create (&monitor_thread_id, 0, &monitor_thread, 0); + Threads::ThreadManager thread_manager; + Threads::spawn (thread_manager, + Threads::encapsulate (&monitor_parent_liveness) + .collect_args()); // then go into the action loop... unsigned int N, NZ, NSTEPS, LA, MAXFRT, LIW; @@ -341,10 +344,7 @@ int main () case '7': { // ok, this is the stop - // signal. for this, kill - // the monitor thread, - // and exit gracefully - pthread_kill (monitor_thread_id, SIGKILL); + // signal. exit gracefully exit (0); break; }; @@ -354,6 +354,14 @@ int main () static_cast(action)); }; }; + // exit here explicitly, without + // giving the thread manager a + // chance to wait for the child + // thread, since that will loop + // forever. however, we should + // never be able to get to this + // point anyway... + exit (1); }; -- 2.39.5