| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016 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. |
| 4 |
| 5 #ifndef NET_QUIC_PLATFORM_IMPL_QUIC_MUTEX_IMPL_H_ |
| 6 #define NET_QUIC_PLATFORM_IMPL_QUIC_MUTEX_IMPL_H_ |
| 7 |
| 8 #include "base/synchronization/lock.h" |
| 9 #include "net/quic/platform/api/quic_export.h" |
| 10 |
| 11 #define EXCLUSIVE_LOCK_FUNCTION(x) |
| 12 #define UNLOCK_FUNCTION(x) |
| 13 #define SHARED_LOCK_FUNCTION(x) |
| 14 #define UNLOCK_FUNCTION(x) |
| 15 #define ASSERT_SHARED_LOCK(x) |
| 16 #define LOCKABLE |
| 17 #define SCOPED_LOCKABLE |
| 18 #define GUARDED_BY(x) |
| 19 |
| 20 namespace net { |
| 21 |
| 22 // A class wrapping a non-reentrant mutex. |
| 23 class QUIC_EXPORT_PRIVATE QuicLockImpl { |
| 24 public: |
| 25 QuicLockImpl() = default; |
| 26 |
| 27 // Block until mu_ is free, then acquire it exclusively. |
| 28 void WriterLock() EXCLUSIVE_LOCK_FUNCTION(); |
| 29 |
| 30 // Release mu_. Caller must hold it exclusively. |
| 31 void WriterUnlock() UNLOCK_FUNCTION(); |
| 32 |
| 33 // Block until mu_ is free or shared, then acquire a share of it. |
| 34 void ReaderLock() SHARED_LOCK_FUNCTION(); |
| 35 |
| 36 // Release mu_. Caller could hold it in shared mode. |
| 37 void ReaderUnlock() UNLOCK_FUNCTION(); |
| 38 |
| 39 // Returns immediately if current thread holds mu_ in at least shared |
| 40 // mode. Otherwise, reports an error by crashing with a diagnostic. |
| 41 void AssertReaderHeld() const ASSERT_SHARED_LOCK() {} |
| 42 |
| 43 private: |
| 44 base::Lock lock_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(QuicLockImpl); |
| 47 }; |
| 48 |
| 49 } // namespace net |
| 50 |
| 51 #endif // NET_QUIC_PLATFORM_IMPL_QUIC_MUTEX_IMPL_H_ |
| OLD | NEW |