From: bangerth Date: Fri, 1 Jul 2011 15:39:58 +0000 (+0000) Subject: Add Threads::Thread::valid. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3305577a0066b610e57871c4d2865389fc9e2a7;p=dealii-svn.git Add Threads::Thread::valid. git-svn-id: https://svn.dealii.org/trunk@23910 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/thread_validity_10.cc b/tests/base/thread_validity_10.cc new file mode 100644 index 0000000000..0944eda0ee --- /dev/null +++ b/tests/base/thread_validity_10.cc @@ -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 +#include +#include + +#include + + +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 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 index 0000000000..c5d5f5df19 --- /dev/null +++ b/tests/base/thread_validity_10/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::false +DEAL::true +DEAL::return value = 42