chromium/third_party/google_benchmark/src/src/mutex.h

#ifndef BENCHMARK_MUTEX_H_
#define BENCHMARK_MUTEX_H_

#include <condition_variable>
#include <mutex>

#include "check.h"

// Enable thread safety attributes only with clang.
// The attributes can be safely erased when compiling with other compilers.
#if defined(HAVE_THREAD_SAFETY_ATTRIBUTES)
#define THREAD_ANNOTATION_ATTRIBUTE_
#else
#define THREAD_ANNOTATION_ATTRIBUTE_(x)
#endif

#define CAPABILITY(x)

#define SCOPED_CAPABILITY

#define GUARDED_BY(x)

#define PT_GUARDED_BY(x)

#define ACQUIRED_BEFORE(...)

#define ACQUIRED_AFTER(...)

#define REQUIRES(...)

#define REQUIRES_SHARED(...)

#define ACQUIRE(...)

#define ACQUIRE_SHARED(...)

#define RELEASE(...)

#define RELEASE_SHARED(...)

#define TRY_ACQUIRE(...)

#define TRY_ACQUIRE_SHARED(...)

#define EXCLUDES(...)

#define ASSERT_CAPABILITY(x)

#define ASSERT_SHARED_CAPABILITY(x)

#define RETURN_CAPABILITY(x)

#define NO_THREAD_SAFETY_ANALYSIS

namespace benchmark {

Condition;

// NOTE: Wrappers for std::mutex and std::unique_lock are provided so that
// we can annotate them with thread safety attributes and use the
// -Wthread-safety warning with clang. The standard library types cannot be
// used directly because they do not provide the required annotations.
class CAPABILITY("mutex") Mutex {};

class SCOPED_CAPABILITY MutexLock {};

class Barrier {};

}  // end namespace benchmark

#endif  // BENCHMARK_MUTEX_H_