-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of some concepts from util to C++17
- Loading branch information
Showing
26 changed files
with
543 additions
and
359 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
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
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 |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
// Chair of Algorithms and Data Structures. | ||
// Author: Robin Textor-Falconi <[email protected]> | ||
|
||
#ifndef QLEVER_CANCELLATIONHANDLE_H | ||
#define QLEVER_CANCELLATIONHANDLE_H | ||
#ifndef SRC_UTIL_CANCELLATION_HANDLE_H | ||
#define SRC_UTIL_CANCELLATION_HANDLE_H | ||
|
||
#include <absl/strings/str_cat.h> | ||
#include <gtest/gtest_prod.h> | ||
|
@@ -156,10 +156,14 @@ class CancellationHandle { | |
/// in the console that would otherwise be triggered by the watchdog. | ||
/// NOTE: The parameter state is expected to be one of `CHECK_WINDOW_MISSED` | ||
/// or `WAITING_FOR_CHECK`, otherwise it will violate the correctness check. | ||
void pleaseWatchDog(CancellationState state, | ||
ad_utility::source_location location, | ||
const ad_utility::InvocableWithConvertibleReturnType< | ||
std::string_view> auto& stageInvocable) | ||
CPP_template(typename StateFunc)( | ||
requires ad_utility::InvocableWithConvertibleReturnType< | ||
StateFunc, | ||
std::string_view>) void pleaseWatchDog(CancellationState state, | ||
ad_utility::source_location | ||
location, | ||
const StateFunc& | ||
stageInvocable) | ||
requires WatchDogEnabled { | ||
using DurationType = | ||
std::remove_const_t<decltype(DESIRED_CANCELLATION_CHECK_INTERVAL)>; | ||
|
@@ -215,12 +219,13 @@ class CancellationHandle { | |
/// nothing otherwise. If `WatchDogEnabled` is true, this will log a warning | ||
/// if this check is not called frequently enough. It will contain the | ||
/// filename and line of the caller of this method. | ||
template <ad_utility::InvocableWithConvertibleReturnType<std::string_view> | ||
Func = decltype(detail::printNothing)> | ||
AD_ALWAYS_INLINE void throwIfCancelled( | ||
[[maybe_unused]] ad_utility::source_location location = | ||
ad_utility::source_location::current(), | ||
const Func& stageInvocable = detail::printNothing) { | ||
CPP_template(typename Func = decltype(detail::printNothing))( | ||
requires ad_utility::InvocableWithConvertibleReturnType<Func, | ||
std::string_view>) | ||
AD_ALWAYS_INLINE void throwIfCancelled( | ||
[[maybe_unused]] ad_utility::source_location location = | ||
ad_utility::source_location::current(), | ||
const Func& stageInvocable = detail::printNothing) { | ||
if constexpr (CancellationEnabled) { | ||
auto state = cancellationState_.load(std::memory_order_relaxed); | ||
if (state == CancellationState::NOT_CANCELLED) [[likely]] { | ||
|
@@ -296,4 +301,4 @@ class CancellationHandle { | |
using SharedCancellationHandle = std::shared_ptr<CancellationHandle<>>; | ||
} // namespace ad_utility | ||
|
||
#endif // QLEVER_CANCELLATIONHANDLE_H | ||
#endif // SRC_UTIL_CANCELLATION_HANDLE_H |
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
Oops, something went wrong.