]>
git.proxmox.com Git - ceph.git/blob - ceph/src/zstd/contrib/pzstd/ErrorHolder.h
2 * Copyright (c) 2016-present, Facebook, Inc.
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
18 // Coordinates graceful shutdown of the pzstd pipeline
20 std::atomic
<bool> error_
;
24 ErrorHolder() : error_(false) {}
26 bool hasError() noexcept
{
30 void setError(std::string message
) noexcept
{
31 // Given multiple possibly concurrent calls, exactly one will ever succeed.
32 bool expected
= false;
33 if (error_
.compare_exchange_strong(expected
, true)) {
34 message_
= std::move(message
);
38 bool check(bool predicate
, std::string message
) noexcept
{
40 setError(std::move(message
));
45 std::string
getError() noexcept
{
47 return std::move(message_
);