From 3efe6656b034a18cd730cc8ed11addb7234d2f8c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 21 Apr 2020 13:43:23 -0600 Subject: [PATCH] Remove some pthread vestiges. --- include/deal.II/base/thread_management.h | 79 ++---------------------- source/base/thread_management.cc | 75 ---------------------- 2 files changed, 6 insertions(+), 148 deletions(-) diff --git a/include/deal.II/base/thread_management.h b/include/deal.II/base/thread_management.h index d2e94367c3..ec1cfb248b 100644 --- a/include/deal.II/base/thread_management.h +++ b/include/deal.II/base/thread_management.h @@ -30,15 +30,13 @@ # include # include # include +# include # include # include # include DEAL_II_DISABLE_EXTRA_DIAGNOSTICS # ifdef DEAL_II_WITH_THREADS # include -# ifdef DEAL_II_USE_MT_POSIX -# include -# endif # define TBB_SUPPRESS_DEPRECATED_MESSAGES 1 # include # undef TBB_SUPPRESS_DEPRECATED_MESSAGES @@ -198,10 +196,9 @@ namespace Threads } /** - * Wait for the condition to be signalled. Signal variables need to be + * Wait for the condition to be signaled. Signal variables need to be * guarded by a mutex which needs to be given to this function as an - * argument, see the man page of pthread_cond_wait for a - * description of the mechanisms. + * argument. * * The mutex is assumed held at the entry to this function but is released * upon exit. @@ -220,71 +217,6 @@ namespace Threads std::condition_variable condition_variable; }; -# ifdef DEAL_II_USE_MT_POSIX - /** - * Implementation of a thread barrier class, based on the POSIX thread - * functions. POSIX barriers are a relatively new feature and are not - * supported on all systems. - * - * If the configuration detected the absence of these functions, then - * barriers will not be available, and creating objects of this class will - * result in an exception been thrown unless the count given for the parties - * waiting for the barrier is equal to one (as in this case waiting for the - * barrier is a no-operation, and we can dispense with the POSIX functions - * at all). The rest of the threading functionality will be available in its - * full extent, though, even if POSIX barriers are not available. - * - * @deprecated This class is deprecated. It is easily possible to implement - * its functionality with the facilities provided by C++11. - * - * @author Wolfgang Bangerth, 2002 - */ - class DEAL_II_DEPRECATED PosixThreadBarrier - { - public: - /** - * Constructor. Initialize the underlying POSIX barrier data structure. - */ - PosixThreadBarrier(const unsigned int count, - const char * name = nullptr, - void * arg = nullptr); - - /** - * Destructor. Release all resources. - */ - ~PosixThreadBarrier(); - - /** - * Wait for all threads to reach this point. The return value is zero for - * all participating threads except for one, for which the return value is - * some non-zero value. The operating system picks the special thread by - * some not further known method. - */ - int - wait(); - - private: - /** - * Data object storing the POSIX data which we need to call the POSIX - * functions. - */ -# ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS - pthread_barrier_t barrier; -# else - unsigned int count; -# endif - }; - - - /** - * If using POSIX functions, then alias the POSIX wrapper classes to the - * names we use throughout the library. - * - * @deprecated Like the PosixThreadBarrier class, this `using` declaration - * is deprecated. - */ - using Barrier DEAL_II_DEPRECATED = PosixThreadBarrier; -# endif } // namespace Threads @@ -309,7 +241,8 @@ namespace Threads * Note that this means that only threads created and terminated through the * interfaces of this namespace are taken care of. If threads are created by * directly calling the respective functions of the operating system (e.g. - * pthread_create for the POSIX thread interface), or if they + * pthread_create for the POSIX thread interface, or + * `std::thread` for C++11 facilities), or if they * are killed (e.g. either through pthread_exit from the * spawned thread, or pthread_kill from another thread), then * these events are not registered and counted for the result of this @@ -679,7 +612,7 @@ namespace Threads * anyway since they can not both join the same thread. That said, more * recent C++ standards do not appear to have the requirement any more * that the only thread that can call join() is the one that created the - * thread. Neither does pthread_join appear to have this requirement any + * thread. Neither does `pthread_join` appear to have this requirement any * more. Consequently, we can in fact join from different threads and * we test this in base/thread_validity_07. */ diff --git a/source/base/thread_management.cc b/source/base/thread_management.cc index d63e3f1345..174c95811d 100644 --- a/source/base/thread_management.cc +++ b/source/base/thread_management.cc @@ -148,81 +148,6 @@ namespace Threads -#ifdef DEAL_II_USE_MT_POSIX - - -# ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS - PosixThreadBarrier::PosixThreadBarrier(const unsigned int count, - const char *, - void *) - { - pthread_barrier_init(&barrier, nullptr, count); - } - -# else - - PosixThreadBarrier::PosixThreadBarrier(const unsigned int count, - const char *, - void *) - : count(count) - { - // throw an exception unless we - // have the special case that a - // count of 1 is given, since - // then waiting for a barrier is - // a no-op, and we don't need the - // POSIX functionality - AssertThrow(count == 1, - ExcMessage("Your local POSIX installation does not support\n" - "POSIX barriers. You will not be able to use\n" - "this class, but the rest of the threading\n" - "functionality is available.")); - } -# endif - - - - PosixThreadBarrier::~PosixThreadBarrier() - { -# ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS - pthread_barrier_destroy(&barrier); -# else - // unless the barrier is a no-op, - // complain again (how did we get - // here then?) - if (count != 1) - std::abort(); -# endif - } - - - - int - PosixThreadBarrier::wait() - { -# ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS - return pthread_barrier_wait(&barrier); -# else - // in the special case, this - // function is a no-op. otherwise - // complain about the missing - // POSIX functions - if (count == 1) - return 0; - else - { - std::abort(); - return 1; - } -# endif - } - - - -#endif - - - std::vector> split_interval(const unsigned int begin, const unsigned int end, -- 2.39.5