Index: third_party/WebKit/Source/platform/scheduler/base/moveable_auto_lock.h |
diff --git a/third_party/WebKit/Source/platform/scheduler/base/moveable_auto_lock.h b/third_party/WebKit/Source/platform/scheduler/base/moveable_auto_lock.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c92a8bb3510a34eba98c0f24ae6616a5af5f40fa |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/scheduler/base/moveable_auto_lock.h |
@@ -0,0 +1,41 @@ |
+// Copyright 206 The Chromium Authors. All rights reserved. |
Sami
2016/12/09 11:04:02
2016 :)
alex clarke (OOO till 29th)
2016/12/12 11:45:04
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_MOVEABLE_AUTO_LOCK_H_ |
+#define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_MOVEABLE_AUTO_LOCK_H_ |
+ |
+#include "base/synchronization/lock.h" |
+ |
+namespace blink { |
+namespace scheduler { |
+ |
+class MoveableAutoLock { |
+ public: |
+ explicit MoveableAutoLock(base::Lock& lock) : lock_(lock), moved_(false) { |
+ lock_.Acquire(); |
+ } |
+ |
+ explicit MoveableAutoLock(MoveableAutoLock&& other) |
+ : lock_(other.lock_), moved_(other.moved_) { |
+ lock_.AssertAcquired(); |
+ other.moved_ = true; |
+ } |
+ |
+ ~MoveableAutoLock() { |
+ if (moved_) |
+ return; |
+ lock_.AssertAcquired(); |
+ lock_.Release(); |
+ } |
+ |
+ private: |
+ base::Lock& lock_; |
+ bool moved_; |
+ DISALLOW_COPY_AND_ASSIGN(MoveableAutoLock); |
+}; |
+ |
+} // namespace scheduler |
+} // namespace blink |
+ |
+#endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_MOVEABLE_AUTO_LOCK_H_ |