]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add Threads::Thread::valid.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Jul 2011 15:39:58 +0000 (15:39 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Jul 2011 15:39:58 +0000 (15:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@23910 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/thread_validity_10.cc [new file with mode: 0644]
tests/base/thread_validity_10/cmp/generic [new file with mode: 0644]

diff --git a/tests/base/thread_validity_10.cc b/tests/base/thread_validity_10.cc
new file mode 100644 (file)
index 0000000..0944eda
--- /dev/null
@@ -0,0 +1,56 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2008, 2009, 2011 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//-----------------------------------------------------------------------------
+
+// see that we can query a thread object that has never been
+// assigned
+
+#include "../tests.h"
+#include <iomanip>
+#include <fstream>
+#include <unistd.h>
+
+#include <deal.II/base/thread_management.h>
+
+
+Threads::Mutex mutex;
+int spin_lock = 0;
+
+
+int worker ()
+{
+  sleep (1);
+  return 42;
+}
+
+
+
+int main()
+{
+  std::ofstream logfile("thread_validity_10/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Threads::Thread<int> t;
+                                  // join non-existing thread
+  deallog << (t.valid() ? "true" : "false")
+         << std::endl;
+
+                                  // now assign a thread object and
+                                  // wait for it
+  t = Threads::new_thread (worker);
+  deallog << (t.valid() ? "true" : "false")
+         << std::endl;
+  deallog << "return value = " << t.return_value()
+         << std::endl;
+}
diff --git a/tests/base/thread_validity_10/cmp/generic b/tests/base/thread_validity_10/cmp/generic
new file mode 100644 (file)
index 0000000..c5d5f5d
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::false
+DEAL::true
+DEAL::return value = 42

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.