Files
scylladb/utils/memory_limit_reached.hh
Avi Kivity f3eade2f62 treewide: relicense to ScyllaDB-Source-Available-1.0
Drop the AGPL license in favor of a source-available license.
See the blog post [1] for details.

[1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
2024-12-18 17:45:13 +02:00

29 lines
826 B
C++

/*
* Copyright (C) 2023-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include <string>
namespace utils {
// An exception thrown when a certain process or task is being terminated because
// it has reached the memory limit allotted for said task or task group.
// This is distinct from a regular bad-alloc in that possibly there is still
// memory available but not for the task being terminated.
// Allows code like LSA to tell real alloc failure from artificial one and act
// accordingly (not retry the task).
class memory_limit_reached : public std::bad_alloc {
std::string _msg;
public:
memory_limit_reached(std::string_view msg) : _msg(msg) { }
const char* what() const noexcept override { return _msg.c_str(); }
};
} // namespace utils