| 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 #ifndef EXCLUSIVE_LOCK_FUNCTION |
| 12 #define EXCLUSIVE_LOCK_FUNCTION(...) |
| 13 #endif |
| 14 |
| 15 #ifndef UNLOCK_FUNCTION |
| 16 #define UNLOCK_FUNCTION(...) |
| 17 #endif |
| 18 |
| 19 #ifndef SHARED_LOCK_FUNCTION |
| 20 #define SHARED_LOCK_FUNCTION(...) |
| 21 #endif |
| 22 |
| 23 #ifndef ASSERT_SHARED_LOCK |
| 24 #define ASSERT_SHARED_LOCK(...) |
| 25 #endif |
| 26 |
| 27 #ifndef LOCKABLE |
| 28 #define LOCKABLE |
| 29 #endif |
| 30 |
| 31 #ifndef SCOPED_LOCKABLE |
| 32 #define SCOPED_LOCKABLE |
| 33 #endif |
| 34 |
| 35 #ifndef GUARDED_BY |
| 36 #define GUARDED_BY(x) |
| 37 #endif |
| 38 |
| 39 namespace net { |
| 40 |
| 41 // A class wrapping a non-reentrant mutex. |
| 42 class QUIC_EXPORT_PRIVATE QuicLockImpl { |
| 43 public: |
| 44 QuicLockImpl() = default; |
| 45 |
| 46 // Block until lock_ is free, then acquire it exclusively. |
| 47 void WriterLock() EXCLUSIVE_LOCK_FUNCTION(); |
| 48 |
| 49 // Release lock_. Caller must hold it exclusively. |
| 50 void WriterUnlock() UNLOCK_FUNCTION(); |
| 51 |
| 52 // Block until lock_ is free or shared, then acquire a share of it. |
| 53 void ReaderLock() SHARED_LOCK_FUNCTION(); |
| 54 |
| 55 // Release lock_. Caller could hold it in shared mode. |
| 56 void ReaderUnlock() UNLOCK_FUNCTION(); |
| 57 |
| 58 // Not implemented. |
| 59 void AssertReaderHeld() const ASSERT_SHARED_LOCK() {} |
| 60 |
| 61 private: |
| 62 base::Lock lock_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(QuicLockImpl); |
| 65 }; |
| 66 |
| 67 } // namespace net |
| 68 |
| 69 #endif // NET_QUIC_PLATFORM_IMPL_QUIC_MUTEX_IMPL_H_ |
| OLD | NEW |