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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/platform/impl/quic_mutex_impl.h
diff --git a/net/quic/platform/impl/quic_mutex_impl.h b/net/quic/platform/impl/quic_mutex_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..fae020a7a41991d9460e3abd7dba2c82d97517bc
--- /dev/null
+++ b/net/quic/platform/impl/quic_mutex_impl.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_MUTEX_IMPL_H_
+#define NET_QUIC_PLATFORM_IMPL_QUIC_MUTEX_IMPL_H_
+
+#include "base/synchronization/lock.h"
+#include "net/quic/platform/api/quic_export.h"
+
+#ifndef EXCLUSIVE_LOCK_FUNCTION
+#define EXCLUSIVE_LOCK_FUNCTION(...)
+#endif
+
+#ifndef UNLOCK_FUNCTION
+#define UNLOCK_FUNCTION(...)
+#endif
+
+#ifndef SHARED_LOCK_FUNCTION
+#define SHARED_LOCK_FUNCTION(...)
+#endif
+
+#ifndef ASSERT_SHARED_LOCK
+#define ASSERT_SHARED_LOCK(...)
+#endif
+
+#ifndef LOCKABLE
+#define LOCKABLE
+#endif
+
+#ifndef SCOPED_LOCKABLE
+#define SCOPED_LOCKABLE
+#endif
+
+#ifndef GUARDED_BY
+#define GUARDED_BY(x)
+#endif
+
+namespace net {
+
+// A class wrapping a non-reentrant mutex.
+class QUIC_EXPORT_PRIVATE QuicLockImpl {
+ public:
+ QuicLockImpl() = default;
+
+ // Block until lock_ is free, then acquire it exclusively.
+ void WriterLock() EXCLUSIVE_LOCK_FUNCTION();
+
+ // Release lock_. Caller must hold it exclusively.
+ void WriterUnlock() UNLOCK_FUNCTION();
+
+ // Block until lock_ is free or shared, then acquire a share of it.
+ void ReaderLock() SHARED_LOCK_FUNCTION();
+
+ // Release lock_. Caller could hold it in shared mode.
+ void ReaderUnlock() UNLOCK_FUNCTION();
+
+ // Not implemented.
+ void AssertReaderHeld() const ASSERT_SHARED_LOCK() {}
+
+ private:
+ base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(QuicLockImpl);
+};
+
+} // namespace net
+
+#endif // NET_QUIC_PLATFORM_IMPL_QUIC_MUTEX_IMPL_H_
« 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