// The necessary files from the deal.II library.
#include <deal.II/base/logstream.h>
+#include <deal.II/base/multithread_info.h>
#include <deal.II/base/utilities.h>
#include <deal.II/base/function.h>
#include <deal.II/base/conditional_ostream.h>
#include <deal.II/base/config.h>
#include <deal.II/base/function.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/point.h>
-#include <deal.II/base/thread_management.h>
DEAL_II_NAMESPACE_OPEN
#ifdef DEAL_II_WITH_GSL
# include <deal.II/base/function.h>
+# include <deal.II/base/mutex.h>
# include <deal.II/base/point.h>
-# include <deal.II/base/thread_management.h>
# include <gsl/gsl_spline.h>
#include <deal.II/base/config.h>
#include <deal.II/base/function.h>
-#include <deal.II/base/thread_management.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/lac/vector.h>
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
-#include <deal.II/base/thread_management.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/utilities.h>
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2000 - 2022 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii_mutex_h
+#define dealii_mutex_h
+
+
+#include <deal.II/base/config.h>
+
+#include <mutex>
+
+DEAL_II_NAMESPACE_OPEN
+
+/**
+ * @addtogroup threads
+ * @{
+ */
+
+namespace Threads
+{
+ /**
+ * A class implementing a <a
+ * href="https://en.wikipedia.org/wiki/Lock_(computer_science)">mutex</a>.
+ * Mutexes are used to lock data structures to ensure that only a
+ * single thread of execution can access them at the same time.
+ *
+ * This class is a thin wrapper around `std::mutex`. The only difference
+ * is that this class is copyable when `std::mutex` is not. Indeed, when
+ * copied, the receiving object does not copy any state from the object
+ * being copied, i.e. an entirely new mutex is created. These semantics
+ * are consistent with the common use case if a mutex is used as a member
+ * variable to lock the other member variables of a class: in that case,
+ * the mutex of the copied-to object should only guard the members of the
+ * copied-to object, not the members of both the copied-to and
+ * copied-from object. Since at the time when the class is copied, the
+ * destination's member variable is not used yet, its corresponding mutex
+ * should also remain in its original state.
+ */
+ class Mutex : public std::mutex
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ Mutex() = default;
+
+ /**
+ * Copy constructor. As discussed in this class's documentation, no state
+ * is copied from the object given as argument.
+ */
+ Mutex(const Mutex &)
+ : std::mutex()
+ {}
+
+ /**
+ * Copy operators. As discussed in this class's documentation, no state
+ * is copied from the object given as argument.
+ */
+ Mutex &
+ operator=(const Mutex &)
+ {
+ return *this;
+ }
+ };
+} // namespace Threads
+
+/**
+ * @}
+ */
+
+DEAL_II_NAMESPACE_CLOSE
+#endif
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/synchronous_iterator.h>
#include <deal.II/base/template_constraints.h>
-#include <deal.II/base/thread_management.h>
#include <cstddef>
#include <functional>
/**
* A mutex to guard the access to the in_use flag.
*/
- std::mutex mutex;
+ Threads::Mutex mutex;
#endif
};
} // namespace internal
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/point.h>
#include <deal.II/base/polynomial.h>
#include <deal.II/base/polynomial_space.h>
#include <deal.II/base/tensor.h>
#include <deal.II/base/tensor_polynomials_base.h>
#include <deal.II/base/tensor_product_polynomials.h>
-#include <deal.II/base/thread_management.h>
#include <memory>
#include <vector>
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/point.h>
#include <deal.II/base/polynomial.h>
#include <deal.II/base/polynomial_space.h>
#include <deal.II/base/tensor.h>
#include <deal.II/base/tensor_polynomials_base.h>
-#include <deal.II/base/thread_management.h>
#include <vector>
// ---------------------------------------------------------------------
#ifndef dealii_thread_management_h
-# define dealii_thread_management_h
+#define dealii_thread_management_h
-# include <deal.II/base/config.h>
+#include <deal.II/base/config.h>
-# include <deal.II/base/exceptions.h>
-# include <deal.II/base/multithread_info.h>
-# include <deal.II/base/std_cxx17/tuple.h>
-# include <deal.II/base/template_constraints.h>
+#include <deal.II/base/exceptions.h>
+#include <deal.II/base/multithread_info.h>
+#include <deal.II/base/mutex.h>
+#include <deal.II/base/std_cxx17/tuple.h>
+#include <deal.II/base/template_constraints.h>
-# include <atomic>
-# include <functional>
-# include <future>
-# include <list>
-# include <memory>
-# include <mutex>
-# include <thread>
-# include <utility>
-# include <vector>
+#include <atomic>
+#include <functional>
+#include <future>
+#include <list>
+#include <memory>
+#include <thread>
+#include <utility>
+#include <vector>
-# ifdef DEAL_II_WITH_TBB
+#ifdef DEAL_II_WITH_TBB
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
-# include <tbb/task_group.h>
+# include <tbb/task_group.h>
DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
-# endif
+#endif
DEAL_II_NAMESPACE_OPEN
*
* @ingroup threads
*/
-namespace Threads
-{
- /**
- * A class implementing a <a
- * href="https://en.wikipedia.org/wiki/Lock_(computer_science)">mutex</a>.
- * Mutexes are used to lock data structures to ensure that only a
- * single thread of execution can access them at the same time.
- *
- * This class is a thin wrapper around `std::mutex`. The only difference
- * is that this class is copyable when `std::mutex` is not. Indeed, when
- * copied, the receiving object does not copy any state from the object
- * being copied, i.e. an entirely new mutex is created. These semantics
- * are consistent with the common use case if a mutex is used as a member
- * variable to lock the other member variables of a class: in that case,
- * the mutex of the copied-to object should only guard the members of the
- * copied-to object, not the members of both the copied-to and
- * copied-from object. Since at the time when the class is copied, the
- * destination's member variable is not used yet, its corresponding mutex
- * should also remain in its original state.
- */
- class Mutex : public std::mutex
- {
- public:
- /**
- * Default constructor.
- */
- Mutex() = default;
-
- /**
- * Copy constructor. As discussed in this class's documentation, no state
- * is copied from the object given as argument.
- */
- Mutex(const Mutex &)
- : std::mutex()
- {}
-
- /**
- * Copy operators. As discussed in this class's documentation, no state
- * is copied from the object given as argument.
- */
- Mutex &
- operator=(const Mutex &)
- {
- return *this;
- }
- };
-} // namespace Threads
-
-
namespace Threads
{
/**
} // namespace Threads
/* ----------- implementation of functions in namespace Threads ---------- */
-# ifndef DOXYGEN
+#ifndef DOXYGEN
namespace Threads
{
template <typename ForwardIterator>
}
} // namespace Threads
-# endif // DOXYGEN
+#endif // DOXYGEN
namespace Threads
{
{
if (MultithreadInfo::n_threads() > 1)
{
-# ifdef DEAL_II_WITH_TBB
+#ifdef DEAL_II_WITH_TBB
// Create a promise object and from it extract a future that
// we can use to refer to the outcome of the task. For reasons
// explained below, we can't just create a std::promise object,
}
});
-# else
+#else
// If no threading library is supported, just fall back onto C++11
// facilities. The problem with this is that the standard does
// not actually say what std::async should do. The first
task_data = std::make_shared<TaskData>(
std::async(std::launch::async | std::launch::deferred,
function_object));
-# endif
+#endif
}
else
{
return;
else
{
-# ifdef DEAL_II_WITH_TBB
+#ifdef DEAL_II_WITH_TBB
// If we build on the TBB, then we can't just wait for the
// std::future object to get ready. Apparently the TBB happily
// enqueues a task into an arena and then just sits on it without
// tbb::task_group, and then here wait for the single task
// associated with that task group.
task_group.wait();
-# endif
+#endif
// Wait for the task to finish and then move its
// result. (We could have made the set_from() function
*/
internal::return_value<RT> returned_object;
-# ifdef DEAL_II_WITH_TBB
+#ifdef DEAL_II_WITH_TBB
/**
* A task group object we can wait for.
*/
tbb::task_group task_group;
friend class Task<RT>;
-# endif
+#endif
};
/**
*/
-//---------------------------------------------------------------------------
DEAL_II_NAMESPACE_CLOSE
-// end of #ifndef dealii_thread_management_h
#endif
-//---------------------------------------------------------------------------
#include <deal.II/base/conditional_ostream.h>
#include <deal.II/base/mpi.h>
-#include <deal.II/base/thread_management.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/utilities.h>
#include <chrono>
#include <deal.II/base/config.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/tensor_product_polynomials.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/fe/fe_poly.h>
#include <deal.II/base/config.h>
#include <deal.II/base/geometry_info.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/polynomial.h>
#include <deal.II/base/polynomials_nedelec.h>
#include <deal.II/base/table.h>
#include <deal.II/base/tensor.h>
#include <deal.II/base/tensor_product_polynomials.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/fe/fe.h>
#include <deal.II/fe/fe_poly_tensor.h>
#include <deal.II/base/config.h>
#include <deal.II/base/derivative_form.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/quadrature.h>
#include <deal.II/base/tensor_polynomials_base.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/fe/fe.h>
/**
* A mutex to be used to guard access to the variables below.
*/
- mutable std::mutex cache_mutex;
+ mutable Threads::Mutex cache_mutex;
/**
* If a shape function is computed at a single point, we must compute all of
#include <deal.II/base/config.h>
-#include <deal.II/base/thread_management.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/fe/fe_poly.h>
#include <deal.II/base/config.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/table.h>
#include <deal.II/fe/fe.h>
#include <deal.II/base/config.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/polynomials_barycentric.h>
#include <deal.II/fe/fe_poly.h>
#include <deal.II/base/config.h>
#include <deal.II/base/mg_level_object.h>
-#include <deal.II/base/thread_management.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/dofs/dof_handler.h>
/**
* A variable to guard access to the fe_values variable.
*/
- mutable std::mutex fe_values_mutex;
+ mutable Threads::Mutex fe_values_mutex;
void
compute_data(const UpdateFlags update_flags,
#include <deal.II/base/config.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/smartpointer.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/base/config.h>
#include <deal.II/base/memory_consumption.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/table.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/base/utilities.h>
#include <deal.II/lac/block_indices.h>
#include <deal.II/lac/vector_operation.h>
#include <cmath>
+#include <mutex>
DEAL_II_NAMESPACE_OPEN
* A mutex variable used to guard access to the member variables of this
* structure;
*/
- std::mutex mutex;
+ Threads::Mutex mutex;
/**
* Copy operator. This is needed because the default copy operator of this
#include <deal.II/base/parallel.h>
#include <deal.II/base/partitioner.h>
#include <deal.II/base/subscriptor.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/lac/vector_operation.h>
#include <deal.II/lac/vector_space_vector.h>
#include <deal.II/base/config.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/table.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/lac/lapack_support.h>
#include <deal.II/lac/vector_memory.h>
/**
* Thread mutex.
*/
- mutable std::mutex mutex;
+ mutable Threads::Mutex mutex;
};
#include <deal.II/base/cuda_size.h>
#include <deal.II/base/memory_space.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/parallel.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/template_constraints.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/base/utilities.h>
#include <deal.II/lac/affine_constraints.h>
# include <deal.II/base/exceptions.h>
# include <deal.II/base/mpi.h>
+# include <deal.II/base/mutex.h>
# include <deal.II/base/process_grid.h>
-# include <deal.II/base/thread_management.h>
# include <deal.II/lac/full_matrix.h>
# include <deal.II/lac/lapack_full_matrix.h>
#include <deal.II/base/config.h>
#include <deal.II/base/array_view.h>
-#include <deal.II/base/thread_management.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/lac/lapack_full_matrix.h>
#include <deal.II/base/config.h>
#include <deal.II/base/logstream.h>
+#include <deal.II/base/mutex.h>
#include <deal.II/base/smartpointer.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/lac/vector.h>
#include <deal.II/base/config.h>
#include <deal.II/base/memory_consumption.h>
-#include <deal.II/base/multithread_info.h>
#include <deal.II/base/parallel.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/lac/affine_constraints.h>
#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/base/config.h>
#include <deal.II/base/memory_consumption.h>
-#include <deal.II/base/multithread_info.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/base/utilities.h>
#include <deal.II/fe/fe_dgq.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/mpi.h>
#include <deal.II/base/mpi_consensus_algorithms.h>
+#include <deal.II/base/multithread_info.h>
#include <deal.II/base/polynomials_piecewise.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/tensor_product_polynomials.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/mpi.h>
#include <deal.II/base/tensor.h>
-#include <deal.II/base/thread_management.h>
#include <deal.II/base/utilities.h>
#include <deal.II/base/vectorization.h>
#include <deal.II/base/geometry_info.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/mpi.templates.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/distributed/cell_data_transfer.templates.h>
#include <deal.II/distributed/fully_distributed_tria.h>
#include <deal.II/base/tensor_product_polynomials.h>
#include <deal.II/base/tensor_product_polynomials_bubbles.h>
#include <deal.II/base/tensor_product_polynomials_const.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/fe/fe_dgp.h>
#include <deal.II/fe/fe_dgq.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/quadrature.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/base/numbers.h>
#include <deal.II/base/quadrature.h>
#include <deal.II/base/signaling_nan.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/differentiation/ad.h>
#include <deal.II/base/geometry_info.h>
#include <deal.II/base/memory_consumption.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/fe/mapping_q1.h>
//
// ---------------------------------------------------------------------
+#include <deal.II/base/thread_management.h>
+
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/non_matching/fe_immersed_values.h>