Introduces a utility function which allows obtaining a pointer to the exception data held behind an std::exception_ptr if the data matches the requested type. It can be used to implement manual but concise try..catch chains. The `try_catch` has the best performance when used with libstdc++ as it uses the stdlib specific functions for simulating a try..catch without having to actually throw. For other stdlibs, the implementation falls back to a throw surrounded by an actual try..catch.
31 lines
639 B
C++
31 lines
639 B
C++
/*
|
|
* Copyright (C) 2022-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#if defined(NO_OPTIMIZED_EXCEPTION_HANDLING)
|
|
#undef NO_OPTIMIZED_EXCEPTION_HANDLING
|
|
#endif
|
|
|
|
#include "utils/exceptions.hh"
|
|
|
|
#if defined(OPTIMIZED_EXCEPTION_HANDLING_AVAILABLE)
|
|
|
|
#include "exceptions_test.inc.cc"
|
|
|
|
#else
|
|
|
|
#include <boost/test/unit_test_log.hpp>
|
|
#include <seastar/testing/test_case.hh>
|
|
|
|
SEASTAR_TEST_CASE(test_noop) {
|
|
BOOST_TEST_MESSAGE("Optimized implementation of handling exceptions "
|
|
"without throwing is not available. Skipping tests in this file.");
|
|
return seastar::make_ready_future<>();
|
|
}
|
|
|
|
#endif
|