From b3d6c438a0f62c362bd18084b82d8615a4dbaf4c Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 18 Feb 2018 19:20:17 -0500 Subject: [PATCH] Move an implementation to a source file. --- include/deal.II/base/parallel.h | 34 +++------------------ source/base/parallel.cc | 52 ++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/include/deal.II/base/parallel.h b/include/deal.II/base/parallel.h index ad3e37e36c..b3db498933 100644 --- a/include/deal.II/base/parallel.h +++ b/include/deal.II/base/parallel.h @@ -703,25 +703,14 @@ namespace parallel /** * Constructor. */ - TBBPartitioner() -#ifdef DEAL_II_WITH_THREADS - : - my_partitioner(std::make_shared()), - in_use(false) -#endif - {} + TBBPartitioner(); #ifdef DEAL_II_WITH_THREADS /** * Destructor. Check that the object is not in use any more, i.e., all * loops have been completed. */ - ~TBBPartitioner() - { - AssertNothrow(in_use == false, - ExcInternalError("A vector partitioner goes out of scope, but " - "it appears to be still in use.")); - } + ~TBBPartitioner(); /** * Return an affinity partitioner. In case the partitioner owned by the @@ -730,29 +719,14 @@ namespace parallel * again, return it by the release_one_partitioner() call. */ std::shared_ptr - acquire_one_partitioner() - { - dealii::Threads::Mutex::ScopedLock lock(mutex); - if (in_use) - return std::make_shared(); - - in_use = true; - return my_partitioner; - } + acquire_one_partitioner(); /** * After using the partitioner in a tbb loop through * acquire_one_partitioner(), this call makes the partitioner available * again. */ - void release_one_partitioner(std::shared_ptr &p) - { - if (p.get() == my_partitioner.get()) - { - dealii::Threads::Mutex::ScopedLock lock(mutex); - in_use = false; - } - } + void release_one_partitioner(std::shared_ptr &p); private: /** diff --git a/source/base/parallel.cc b/source/base/parallel.cc index 476b6f02af..1a72567154 100644 --- a/source/base/parallel.cc +++ b/source/base/parallel.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2009 - 2016 by the deal.II authors +// Copyright (C) 2009 - 2018 by the deal.II authors // // This file is part of the deal.II library. // @@ -49,6 +49,56 @@ namespace internal } } +namespace parallel +{ + namespace internal + { +#ifdef DEAL_II_WITH_THREADS + TBBPartitioner::TBBPartitioner() + : + my_partitioner(std::make_shared()), + in_use(false) + {} + + + + TBBPartitioner::~TBBPartitioner() + { + AssertNothrow(in_use == false, + ExcInternalError("A vector partitioner goes out of scope, but " + "it appears to be still in use.")); + } + + + + std::shared_ptr + TBBPartitioner::acquire_one_partitioner() + { + dealii::Threads::Mutex::ScopedLock lock(mutex); + if (in_use) + return std::make_shared(); + + in_use = true; + return my_partitioner; + } + + + + void + TBBPartitioner::release_one_partitioner(std::shared_ptr &p) + { + if (p.get() == my_partitioner.get()) + { + dealii::Threads::Mutex::ScopedLock lock(mutex); + in_use = false; + } + } +#else + TBBPartitioner::TBBPartitioner() = default; +#endif + } +} + -- 2.39.5