Gromacs
2019-rc1
|
#include "gmxpre.h"
#include "gromacs/utility/mutex.h"
#include "config.h"
#include <future>
#include <gtest/gtest.h>
Tests for gmx::Mutex.
These tests ensure that basic mutual-exclusion properties hold. Note that no testing can prove there isn't a bug, but if one exists, then these tests might expose one.
In particular, try_lock can be implemented differently on different platforms, or with different default mutex types, so we should check that the behaviour continues to conform with the thread-MPI documentation.
Classes | |
class | gmx::test::anonymous_namespace{mutex.cpp}::DifferentTasksTest |
Parameterized test fixture. More... | |
Typedefs | |
using | gmx::test::anonymous_namespace{mutex.cpp}::Lock = gmx::lock_guard< Mutex > |
Convenience definition. | |
using | gmx::test::anonymous_namespace{mutex.cpp}::TaskType = std::function< int(void)> |
Function type for asynchronous tasks. | |
Functions | |
int | gmx::test::anonymous_namespace{mutex.cpp}::updateSharedValue () |
A task that just does work. | |
int | gmx::test::anonymous_namespace{mutex.cpp}::updateSharedValueWithLock () |
A task that does work after it gets the mutex. | |
int | gmx::test::anonymous_namespace{mutex.cpp}::updateSharedValueWithTryLock () |
A task that does work only if it can get the mutex immediately. | |
Variables | |
int | gmx::test::anonymous_namespace{mutex.cpp}::g_sharedValue |
A shared value for a mutex to protect. | |
Mutex | gmx::test::anonymous_namespace{mutex.cpp}::g_sharedValueMutex |
A mutex to protect a shared value. | |