Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: net/quic/platform/impl/quic_mutex_impl.h

Issue 2561913003: Create a QUIC wrapper around a mutex and a mutex lock. (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/platform/api/quic_mutex.cc ('k') | net/quic/platform/impl/quic_mutex_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_
OLDNEW
« no previous file with comments | « net/quic/platform/api/quic_mutex.cc ('k') | net/quic/platform/impl/quic_mutex_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698