Commit c5b56704 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[tasks] Cleanup OperationsBarrier

The class disallows copy construction, but still allows copy assignment.
This is fixed in this CL.

Drive-by: Fix punctuation.
Drive-by 2: Fix indentation in code example.

R=etiennep@chromium.org

Bug: v8:11074
Change-Id: I09e993a69d72e262d7b220200ef94b36d346548e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2584246Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71828}
parent 1314d2b8
......@@ -35,9 +35,7 @@ namespace internal {
// }
//
// void MaybeRunOperation() {
// auto token = barrier_.TryLock();
// if (token)
// Process();
// if (token = barrier_.TryLock()) Process();
// }
//
class V8_EXPORT_PRIVATE OperationsBarrier {
......@@ -46,7 +44,7 @@ class V8_EXPORT_PRIVATE OperationsBarrier {
// operation while being certain it happens-before CancelAndWait(). Releasing
// this Token relinquishes this right.
//
// This class is thread-safe
// This class is thread-safe.
class Token {
public:
Token() = default;
......@@ -54,11 +52,19 @@ class V8_EXPORT_PRIVATE OperationsBarrier {
if (outer_) outer_->Release();
}
Token(const Token&) = delete;
Token(Token&& other) V8_NOEXCEPT {
this->outer_ = other.outer_;
Token(Token&& other) V8_NOEXCEPT : outer_(other.outer_) {
other.outer_ = nullptr;
}
Token& operator=(const Token&) = delete;
Token& operator=(Token&& other) V8_NOEXCEPT {
DCHECK_NE(this, &other);
if (outer_) outer_->Release();
outer_ = other.outer_;
other.outer_ = nullptr;
return *this;
}
operator bool() const { return !!outer_; }
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment