| 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..846750e2b02eb2f323a01b649cdcd29ef492b39e
|
| --- /dev/null
|
| +++ b/net/quic/platform/impl/quic_mutex_impl.h
|
| @@ -0,0 +1,51 @@
|
| +// 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"
|
| +
|
| +#define EXCLUSIVE_LOCK_FUNCTION(x)
|
| +#define UNLOCK_FUNCTION(x)
|
| +#define SHARED_LOCK_FUNCTION(x)
|
| +#define UNLOCK_FUNCTION(x)
|
| +#define ASSERT_SHARED_LOCK(x)
|
| +#define LOCKABLE
|
| +#define SCOPED_LOCKABLE
|
| +#define GUARDED_BY(x)
|
| +
|
| +namespace net {
|
| +
|
| +// A class wrapping a non-reentrant mutex.
|
| +class QUIC_EXPORT_PRIVATE QuicLockImpl {
|
| + public:
|
| + QuicLockImpl() = default;
|
| +
|
| + // Block until mu_ is free, then acquire it exclusively.
|
| + void WriterLock() EXCLUSIVE_LOCK_FUNCTION();
|
| +
|
| + // Release mu_. Caller must hold it exclusively.
|
| + void WriterUnlock() UNLOCK_FUNCTION();
|
| +
|
| + // Block until mu_ is free or shared, then acquire a share of it.
|
| + void ReaderLock() SHARED_LOCK_FUNCTION();
|
| +
|
| + // Release mu_. Caller could hold it in shared mode.
|
| + void ReaderUnlock() UNLOCK_FUNCTION();
|
| +
|
| + // Returns immediately if current thread holds mu_ in at least shared
|
| + // mode. Otherwise, reports an error by crashing with a diagnostic.
|
| + 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_
|
|
|