#include <boost/scoped_ptr.hpp>
-#include "thread_mpi/mutex.h"
-
#include "buildinfo.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/mutex.h"
#include "gromacs/utility/path.h"
#include "gromacs/utility/stringutil.h"
mutable std::string fullBinaryPath_;
mutable std::string installationPrefix_;
mutable bool bSourceLayout_;
- mutable tMPI::mutex binaryPathMutex_;
+ mutable Mutex binaryPathMutex_;
};
CommandLineProgramContext::Impl::Impl()
const char *CommandLineProgramContext::fullBinaryPath() const
{
- tMPI::lock_guard<tMPI::mutex> lock(impl_->binaryPathMutex_);
+ lock_guard<Mutex> lock(impl_->binaryPathMutex_);
impl_->findBinaryPath();
return impl_->fullBinaryPath_.c_str();
}
InstallationPrefixInfo CommandLineProgramContext::installationPrefix() const
{
- tMPI::lock_guard<tMPI::mutex> lock(impl_->binaryPathMutex_);
+ lock_guard<Mutex> lock(impl_->binaryPathMutex_);
if (impl_->installationPrefix_.empty())
{
impl_->findBinaryPath();
#endif
#ifdef GMX_FFT_FFTW3
-#include "thread_mpi/mutex.h"
-
#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/mutex.h"
/* none of the fftw3 calls, except execute(), are thread-safe, so
we need to serialize them with this mutex. */
-static tMPI::mutex big_fftw_mutex;
+static gmx::Mutex big_fftw_mutex;
#define FFTW_LOCK try { big_fftw_mutex.lock(); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
#define FFTW_UNLOCK try { big_fftw_mutex.unlock(); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
#endif /* GMX_FFT_FFTW3 */
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2003 David van der Spoel, Erik Lindahl, University of Groningen.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <fftw3.h>
-#include "thread_mpi/mutex.h"
-
#include "gromacs/fft/fft.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/mutex.h"
#ifdef GMX_DOUBLE
#define FFTWPREFIX(name) fftw_ ## name
/* none of the fftw3 calls, except execute(), are thread-safe, so
we need to serialize them with this mutex. */
-static tMPI::mutex big_fftw_mutex;
+static gmx::Mutex big_fftw_mutex;
#define FFTW_LOCK try { big_fftw_mutex.lock(); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
#define FFTW_UNLOCK try { big_fftw_mutex.unlock(); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
#include <algorithm>
#include <vector>
-#include "thread_mpi/mutex.h"
-
#include "gromacs/legacyheaders/names.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/mutex.h"
#include "gromacs/utility/stringutil.h"
namespace gmx
//! Data structure to hold the grid cell contents.
CellList cells_;
- tMPI::mutex createPairSearchMutex_;
+ Mutex createPairSearchMutex_;
PairSearchList pairSearchList_;
friend class AnalysisNeighborhoodPairSearchImpl;
AnalysisNeighborhoodSearchImpl::PairSearchImplPointer
AnalysisNeighborhoodSearchImpl::getPairSearch()
{
- tMPI::lock_guard<tMPI::mutex> lock(createPairSearchMutex_);
+ lock_guard<Mutex> lock(createPairSearchMutex_);
// TODO: Consider whether this needs to/can be faster, e.g., by keeping a
// separate pool of unused search objects.
PairSearchList::const_iterator i;
SearchImplPointer getSearch();
- tMPI::mutex createSearchMutex_;
+ Mutex createSearchMutex_;
SearchList searchList_;
real cutoff_;
const t_blocka *excls_;
AnalysisNeighborhood::Impl::SearchImplPointer
AnalysisNeighborhood::Impl::getSearch()
{
- tMPI::lock_guard<tMPI::mutex> lock(createSearchMutex_);
+ lock_guard<Mutex> lock(createSearchMutex_);
// TODO: Consider whether this needs to/can be faster, e.g., by keeping a
// separate pool of unused search objects.
SearchList::const_iterator i;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <cstdlib>
-#include "thread_mpi/mutex.h"
+#include "gromacs/utility/mutex.h"
#include "errorformat.h"
//! Global error handler set with setFatalErrorHandler().
ErrorHandlerFunc g_errorHandler = standardErrorHandler;
//! Mutex for protecting access to ::g_errorHandler.
-tMPI::mutex handler_mutex;
+Mutex handler_mutex;
//! \}
ErrorHandlerFunc setFatalErrorHandler(ErrorHandlerFunc handler)
{
- tMPI::lock_guard<tMPI::mutex> lock(handler_mutex);
- ErrorHandlerFunc oldHandler = g_errorHandler;
+ lock_guard<Mutex> lock(handler_mutex);
+ ErrorHandlerFunc oldHandler = g_errorHandler;
g_errorHandler = handler;
return oldHandler;
}
{
ErrorHandlerFunc handler = NULL;
{
- tMPI::lock_guard<tMPI::mutex> lock(handler_mutex);
+ lock_guard<Mutex> lock(handler_mutex);
handler = g_errorHandler;
}
if (handler != NULL)
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2015, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can 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.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \libinternal \file
+ * \brief
+ * Declares C++11-style basic threading primitives
+ * (gmx::Mutex, gmx::lock_guard).
+ *
+ * For now, the implementation is imported from thread-MPI.
+ *
+ * \author Teemu Murtola <teemu.murtola@gmail.com>
+ * \inlibraryapi
+ * \ingroup module_utility
+ */
+#ifndef GMX_THREADING_MUTEX_H
+#define GMX_THREADING_MUTEX_H
+
+#include "thread_mpi/mutex.h"
+
+namespace gmx
+{
+
+//! \cond libapi
+/*! \libinternal \brief
+ * C++11-compatible basic mutex.
+ */
+typedef tMPI::mutex Mutex;
+//! \endcond
+using tMPI::lock_guard;
+
+} // namespace gmx
+
+#endif
#include <list>
-#include "thread_mpi/mutex.h"
-
#include "gromacs/utility/classhelpers.h"
+#include "gromacs/utility/mutex.h"
namespace gmx
{
//! Adds a provider into the registry.
void add(const char * /*name*/, TestOptionsProvider *provider)
{
- tMPI::lock_guard<tMPI::mutex> lock(listMutex_);
+ lock_guard<Mutex> lock(listMutex_);
providerList_.push_back(provider);
}
typedef std::list<TestOptionsProvider *> ProviderList;
- tMPI::mutex listMutex_;
+ Mutex listMutex_;
ProviderList providerList_;
GMX_DISALLOW_COPY_AND_ASSIGN(TestOptionsRegistry);
{
// TODO: Have some deterministic order for the options; now it depends on
// the order in which the global initializers are run.
- tMPI::lock_guard<tMPI::mutex> lock(listMutex_);
+ lock_guard<Mutex> lock(listMutex_);
ProviderList::const_iterator i;
for (i = providerList_.begin(); i != providerList_.end(); ++i)
{