forked from redpanda-data/redpanda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utils: introduce concurrent_modification_error exception
It is handy to have a base class for all instances of concurrent modifications.
- Loading branch information
Showing
4 changed files
with
43 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 Redpanda Data, Inc. | ||
* | ||
* Use of this software is governed by the Business Source License | ||
* included in the file licenses/BSL.md | ||
* | ||
* As of the Change Date specified in that file, in accordance with | ||
* the Business Source License, use of this software will be governed | ||
* by the Apache License, Version 2.0 | ||
*/ | ||
#pragma once | ||
|
||
#include "base/seastarx.h" | ||
|
||
#include <seastar/core/sstring.hh> | ||
|
||
#include <stdexcept> | ||
|
||
/// Some objects reference state that changes comparatively rarely (e.g. | ||
/// topic_table state) across yield points and expect these references to remain | ||
/// valid. In case these references are invalidated by a concurrent fiber, this | ||
/// exception is thrown. This is a signal for the caller to restart the | ||
/// computation with up-to-date state. | ||
class concurrent_modification_error : public std::exception { | ||
public: | ||
explicit concurrent_modification_error(ss::sstring s) | ||
: _msg(std::move(s)) {} | ||
|
||
const char* what() const noexcept override { return _msg.c_str(); } | ||
|
||
private: | ||
ss::sstring _msg; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters