]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use the deal.II features to create threads.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 1 Oct 2002 16:59:23 +0000 (16:59 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 1 Oct 2002 16:59:23 +0000 (16:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@6577 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/contrib/hsl/source/detached_ma27.cc

index 0a000e50515b082409af7dea910d6c1f9f9843c3..0294d883a023c5f3222cde8687e114592069c2ea 100644 (file)
@@ -12,6 +12,7 @@
 //----------------------------  detached_ma27.cc  ---------------------------
 
 #include <base/config.h>
+#include <base/thread_management.h>
 #include <hsl/hsl.h>
 
 #include <vector>
@@ -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<unsigned short int>(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);
 };
 
                 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.