]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid using unistd.h and sleep 6697/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 30 May 2018 11:25:21 +0000 (13:25 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 30 May 2018 15:28:47 +0000 (17:28 +0200)
29 files changed:
tests/base/mutex_01.cc
tests/base/task_01.cc
tests/base/task_02.cc
tests/base/task_03.cc
tests/base/task_04.cc
tests/base/task_05.cc
tests/base/task_06.cc
tests/base/task_07.cc
tests/base/task_08.cc
tests/base/task_10.cc
tests/base/task_11.cc
tests/base/task_12.cc
tests/base/task_12_capture.cc
tests/base/task_13.cc
tests/base/thread_12.cc
tests/base/thread_local_storage_01.cc
tests/base/thread_local_storage_02.cc
tests/base/thread_local_storage_05.cc
tests/base/thread_local_storage_06.cc
tests/base/thread_validity_07.cc
tests/base/thread_validity_08.cc
tests/base/thread_validity_09.cc
tests/base/thread_validity_10.cc
tests/base/thread_validity_13.cc
tests/base/thread_validity_14.cc
tests/mpi/no_flux_constraints_02.cc
tests/mpi/no_flux_constraints_03.cc
tests/mpi/simple_mpi_01.cc
tests/mpi/trilinos_01.cc

index 348bed2e78ba2cc3358339c29a84b83fbf7e7480..0b4979bac5d8a64ea8342e0451fb498f81d4d316 100644 (file)
@@ -18,8 +18,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -48,7 +46,7 @@ main()
 
   Threads::Thread<> t = Threads::new_thread(&test);
 
-  sleep(2);
+  std::this_thread::sleep_for(std::chrono::seconds(2));
   deallog << "1" << std::endl;
 
   mutex.release();
index 3c8172fe16375ea0463f4a33e09723d5bae806e8..ad9e47e58816acf4171c0f29723c256ac11d16e1 100644 (file)
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
 void
 test()
 {
-  sleep(3);
+  std::this_thread::sleep_for(std::chrono::seconds(3));
   deallog << "OK" << std::endl;
 }
 
index 4390171384263e124e372aac9edb326a835ebaa6..eaae3e8cd7738d2759749ad55f27c1b6e0be71c5 100644 (file)
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
 int
 test()
 {
-  sleep(3);
+  std::this_thread::sleep_for(std::chrono::seconds(3));
   return 42;
 }
 
index 12faacdc4a506690882a7d2498b2a1885d8eed44..b852cc6731f7626779f47ba169ccfe074f16ec6f 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -28,7 +26,7 @@ void
 test(int i)
 {
   deallog << "Task " << i << " starting..." << std::endl;
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 }
 
index aade6c83dbde04394c1787ada737334da618e752..babca60e6eed9722218f417da21f865bf9b87f0d 100644 (file)
@@ -18,8 +18,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -37,7 +35,7 @@ test(int i)
       t2.join();
     }
 
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 }
 
index 9427c6ce44ef7560d3ce0dd28c7c00e5cc02fc0e..358935f924846c7a89a5307dc266742d43f5909f 100644 (file)
@@ -25,8 +25,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
index 2f63e6115706e9cb7c42cc97bdcaa4f98bb6b540..ba49b77c8668aa6f8f943f8bc35f19147f853b40 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -28,7 +26,7 @@ void
 test(int i)
 {
   deallog << "Task " << i << " starting..." << std::endl;
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   if (i < 10)
     {
       Threads::new_task(test, 10 + i).join();
index 34cdf21005f8bf43e0619bc9188c78b46b7147e1..7a668fae734a139352a8342095e2dc30b449de0a 100644 (file)
@@ -18,8 +18,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -27,7 +25,7 @@ void
 test(int i)
 {
   deallog << "Task " << i << " starting..." << std::endl;
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 }
 
index 7d5697b7dd1704c3e2bd0987461e1f47816716b3..05e3051c165e13b6cfd68bd6e9e5c490cb6c3d73 100644 (file)
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
 void
 test(int i)
 {
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 }
 
index 0704a38c83fc28415a62c03035808517bce60c60..e59a48dc8e551df0172067436df049cea81b4995 100644 (file)
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
 void
 test()
 {
-  sleep(3);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "OK" << std::endl;
 }
 
index f57bd27e5a1e0d2440d881a4fe8114599b477ba2..d9eaf588c5a8ad5de1d37fab921e50990d1a27cd 100644 (file)
@@ -18,8 +18,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 Threads::Mutex mutex;
@@ -36,7 +34,7 @@ a_task()
 
   // Sleep some time to make sure all other concurrently running tasks enter
   // here.
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
 
   mutex.acquire();
   n_running--;
index c8127f3596aa8907d7319a521012bbb85fdf4c11..f6e54dd763f7bcd32e9ea56cb669f3d90da5c9de 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -30,7 +28,7 @@ double
 test(int i)
 {
   deallog << "Task " << i << " starting..." << std::endl;
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 
   return 3.141;
index 179a9704bbc14499811e4623f02517e42356f10e..52d2204086dda895fe3ed29bd6f86e9bc2d4e883 100644 (file)
@@ -22,8 +22,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -33,7 +31,7 @@ double
 test(int i)
 {
   deallog << "Task " << i << " starting..." << std::endl;
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 
   return 3.141;
index 6d9d4b2ac8ae2a1fae813db03665c2b5967a4077..c7fa56d8f83f39f7dc506da4bc85dd84ad365300 100644 (file)
@@ -22,8 +22,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -33,7 +31,7 @@ double
 test(int i)
 {
   deallog << "Task " << i << " starting..." << std::endl;
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 
   return 3.141;
index 1b9e152ad1a4f7c066916e90db49c46f9485a3d3..bbd0a8d579624b928d79034e815813b9a0f2137f 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -30,7 +28,7 @@ double
 test(int i)
 {
   deallog << "Task " << i << " starting..." << std::endl;
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   deallog << "Task " << i << " finished!" << std::endl;
 
   return 3.141;
index f4daae2284d41813bd8d3608bf1f955fd174387e..79eddf222623b83550f661315954e11685f02c56 100644 (file)
@@ -56,7 +56,7 @@ execute(int i)
 
   // wait in order to make sure that the
   // thread lives longer than the TLS object
-  sleep(5);
+  std::this_thread::sleep_for(std::chrono::seconds(5));
 }
 
 
index c22136c3e925c0d900e41cfbbe2a13ec137ed474..1b8b464b89b99e1228e6b3c1878e848e1fb370c0 100644 (file)
@@ -66,7 +66,7 @@ execute(int i)
 
   // wait in order to make sure that the
   // thread lives longer than the TLS object
-  sleep(5);
+  std::this_thread::sleep_for(std::chrono::seconds(5));
 }
 
 
index ee4d9183225f3c62d449f3206337c45ad0fdb881..013fbdb97e8d8844a9d4d898eafb8fa1cca8d1db 100644 (file)
@@ -19,8 +19,6 @@
 #include <deal.II/base/thread_local_storage.h>
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -78,7 +76,7 @@ test()
     }
 
   // let threads work through their first part
-  sleep(3);
+  std::this_thread::sleep_for(std::chrono::seconds(3));
 
   // then reset the thread local object and release the mutices so the
   // threads can actually run to an end
index e2f0c1c1409c7527089bfb8fce56661fdaa07da1..3c7829201668cd18b7c2f03321f8fbcfab69d9b1 100644 (file)
@@ -20,8 +20,6 @@
 #include <deal.II/base/thread_local_storage.h>
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -90,7 +88,7 @@ test()
     }
 
   // let threads work through their first part
-  sleep(3);
+  std::this_thread::sleep_for(std::chrono::seconds(3));
 
   // then reset the thread local object and release the mutices so the
   // threads can actually run to an end
index ae72e5400a068355d0e1eb3ca7ee44fab6cdec43..0bc359bd6bf05f1c2aa33c7166cd5760d7394c10 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -28,7 +26,7 @@ void
 worker()
 {
   deallog << "Worker thread is starting." << std::endl;
-  sleep(3);
+  std::this_thread::sleep_for(std::chrono::seconds(3));
   deallog << "Worker thread is finished." << std::endl;
 }
 
index dabfa5b3e52c060cc0c9c54871836a6aaf4a7b1c..795f10bd9cc92c3cb0d6fd0d76927206e8d68473 100644 (file)
@@ -18,8 +18,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include <atomic>
 
 #include "../tests.h"
@@ -65,7 +63,7 @@ main()
   {
     Threads::new_thread(worker);
   }
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
 
   // let abandoned thread continue
   mutex.release();
index 719e1bf7158b43cec0deb6fe63676ab60d0c512b..b4c157b733f56831a96fc35969c722a90426761d 100644 (file)
@@ -21,8 +21,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include <atomic>
 
 #include "../tests.h"
@@ -58,7 +56,7 @@ main()
   {
     Threads::new_thread(worker);
   }
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
 
   const unsigned int sz = 1000000;
   char *             p  = new char[sz];
index 273bba122e24d792c40a2aa1f6b437b3d491cc71..4f8ffd88dfa1692e71dbdff22c0b422b1ee53318 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
@@ -31,7 +29,7 @@ int            spin_lock = 0;
 int
 worker()
 {
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   return 42;
 }
 
index 9e44f873a990bf7c9c810bfd87f19737eb5a80e9..32aa736ec3bd813a503da7ef2f219336ad293ace 100644 (file)
@@ -21,8 +21,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
index d6ee4715bd64ca327054eeba7f73949e925ad448..a4fba249f2afd3864232c0d0bbba2a145609a126 100644 (file)
@@ -21,8 +21,6 @@
 
 #include <deal.II/base/thread_management.h>
 
-#include <unistd.h>
-
 #include "../tests.h"
 
 
index 159ee7a504db02615b11752f3231c4912fc8b142..de07444dc2fae9a2d5a00e9fe5323c519392c168 100644 (file)
@@ -135,7 +135,7 @@ test()
     constraints.print(file);
   }
   MPI_Barrier(MPI_COMM_WORLD);
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   if (myid == 0)
     {
       // sort and merge the constraint matrices on proc 0, generate a checksum
index dddecc3f96480052d8af855b2208820ad30dbbe1..ca051afc778810e850da435874f878cbdb86baf2 100644 (file)
@@ -108,7 +108,7 @@ test()
     constraints.print(file);
   }
   MPI_Barrier(MPI_COMM_WORLD);
-  sleep(1);
+  std::this_thread::sleep_for(std::chrono::seconds(1));
   if (myid == 0)
     {
       // sort and merge the constraint matrices on proc 0, generate a checksum
index e5f2eba5c1bfc1f55b8a09218eab11bc21891920..983423608f7421920462a77ba4e6f92e2187e754 100644 (file)
@@ -39,7 +39,6 @@ test_mpi()
   for (unsigned int i = 1; i < numprocs; ++i)
     {
       MPI_Barrier(MPI_COMM_WORLD);
-      //      system("sleep 1");
 
       if (myid == 0)
         {
index ab8baa1067c30ab5e547974ffb7947f69711bf1e..708e724fac8fc02d1f63ec86c7e199e353b7110e 100644 (file)
@@ -71,7 +71,7 @@ test()
           MPI_Iprobe(0, 12345, MPI_COMM_WORLD, &flag, &status);
           std::cout << flag << std::endl;
 
-          sleep(1);
+          std::this_thread::sleep_for(std::chrono::seconds(1));
         }
 
       Assert(flag != 0, ExcMessage("hang in has_ghost_elements()"));

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.