1 // Copyright (c) 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "thread_annotations.h"
7 #include "testing/gtest/include/gtest/gtest.h"
13 void Acquire() EXCLUSIVE_LOCK_FUNCTION() {}
14 void Release() UNLOCK_FUNCTION() {}
17 class SCOPED_LOCKABLE AutoLock {
19 AutoLock(Lock& lock) EXCLUSIVE_LOCK_FUNCTION(lock) : lock_(lock) {
22 ~AutoLock() UNLOCK_FUNCTION() { lock_.Release(); }
30 void ExplicitIncrement();
31 void ImplicitIncrement();
35 int counter_ GUARDED_BY(lock_);
38 void ThreadSafe::ExplicitIncrement() {
44 void ThreadSafe::ImplicitIncrement() {
45 AutoLock auto_lock(lock_);
49 TEST(ThreadAnnotationsTest, ExplicitIncrement) {
50 ThreadSafe thread_safe;
51 thread_safe.ExplicitIncrement();
53 TEST(ThreadAnnotationsTest, ImplicitIncrement) {
54 ThreadSafe thread_safe;
55 thread_safe.ImplicitIncrement();
58 } // anonymous namespace