Skip to content

Commit e02ecf6

Browse files
committed
Merge remote-tracking branch 'origin/main' into seq-iterate-forward-range
2 parents f73723c + c9d272a commit e02ecf6

85 files changed

Lines changed: 704 additions & 642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ EmptyLineAfterAccessModifier: Never
7171
EmptyLineBeforeAccessModifier: Leave
7272
ExperimentalAutoDetectBinPacking: true
7373
FixNamespaceComments: true
74+
IfMacros: [
75+
STDEXEC_CATCH'
76+
]
7477
IncludeBlocks: Preserve
7578
IndentAccessModifiers: false
7679
IndentCaseBlocks: false
@@ -90,7 +93,7 @@ Macros: [
9093
'STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS=[[no_unique_address]]',
9194
'STDEXEC_MISSING_MEMBER(X,Y)=true',
9295
'STDEXEC_DEFINE_MEMBER(X)=void foo() {}',
93-
'STDEXEC_AUTO_RETURN(...)=->decltype(auto){ return __VA_ARGS__; }'
96+
'STDEXEC_AUTO_RETURN(...)=->decltype(auto){ return __VA_ARGS__; }',
9497
]
9598
MaxEmptyLinesToKeep: 2
9699
NamespaceIndentation: All
@@ -149,6 +152,10 @@ SpacesInConditionalStatement: false
149152
SpacesInContainerLiterals: true
150153
SpacesInParentheses: false
151154
Standard: c++20
155+
StatementMacros: [
156+
'STDEXEC_IF_HOST',
157+
'STDEXEC_IF_DEVICE',
158+
]
152159
TabWidth: 0
153160
TypenameMacros: []
154161
UseTab: Never

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ message(STATUS "Build date : ${STDEXEC_BUILD_DATE}")
6767
message(STATUS "Build year : ${STDEXEC_BUILD_YEAR}")
6868
message(STATUS)
6969

70-
# Integrate with LLVM/clang tooling
71-
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/clangd_compile_info.cmake)
70+
if (STDEXEC_IS_TOP_LEVEL)
71+
# Integrate with LLVM/clang tooling
72+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/clangd_compile_info.cmake)
73+
endif()
7274

7375
# Write the version header
7476
rapids_cmake_write_version_file(include/stdexec_version_config.hpp)

examples/algorithms/retry.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ struct _op {
9191
}
9292

9393
void _retry() noexcept {
94-
try {
94+
STDEXEC_TRY {
9595
o_.emplace(_connect()); // potentially throwing
9696
stdexec::start(*o_);
97-
} catch (...) {
97+
}
98+
STDEXEC_CATCH_ALL {
9899
stdexec::set_error(static_cast<R&&>(r_), std::current_exception());
99100
}
100101
}

examples/algorithms/then.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ class _then_receiver : public stdexec::receiver_adaptor<_then_receiver<R, F>, R>
4141
template <class... As>
4242
requires stdexec::receiver_of<R, _completions<As...>>
4343
void set_value(As&&... as) && noexcept {
44-
try {
44+
STDEXEC_TRY {
4545
stdexec::set_value(
4646
std::move(*this).base(), std::invoke(static_cast<F&&>(f_), static_cast<As&&>(as)...));
47-
} catch (...) {
47+
}
48+
STDEXEC_CATCH_ALL {
4849
stdexec::set_error(std::move(*this).base(), std::current_exception());
4950
}
5051
}

examples/benchmark/static_thread_pool_old.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,15 @@ namespace exec_old {
274274

275275
threads_.reserve(threadCount);
276276

277-
try {
277+
STDEXEC_TRY {
278278
for (std::uint32_t i = 0; i < threadCount; ++i) {
279279
threads_.emplace_back([this, i] { run(i); });
280280
}
281-
} catch (...) {
281+
}
282+
STDEXEC_CATCH_ALL {
282283
request_stop();
283284
join();
284-
throw;
285+
STDEXEC_THROW();
285286
}
286287
}
287288

examples/hello_coro.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ auto async_stop_token() -> exec::task<std::optional<stdexec::inplace_stop_token>
4141
}
4242

4343
auto main() -> int {
44-
try {
44+
STDEXEC_TRY {
4545
// Awaitables are implicitly senders:
4646
auto [i] = stdexec::sync_wait(async_answer2(just(42), just())).value();
4747
std::cout << "The answer is " << i.value() << '\n';
48-
} catch (std::exception& e) {
48+
}
49+
STDEXEC_CATCH(const std::exception& e) {
4950
std::cout << e.what() << '\n';
5051
}
5152
}

examples/server_theme/let_value.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
// Use a thread pool
5353
#include "exec/static_thread_pool.hpp"
5454

55+
#if !STDEXEC_STD_NO_EXCEPTIONS()
5556
namespace ex = stdexec;
5657

5758
struct http_request {
@@ -151,3 +152,11 @@ auto main() -> int {
151152

152153
return 0;
153154
}
155+
156+
#else
157+
158+
int main() {
159+
std::cout << "This example requires C++ exceptions to be enabled.\n";
160+
return 0;
161+
}
162+
#endif // !STDEXEC_STD_NO_EXCEPTIONS()

include/asioexec/completion_token.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ namespace asioexec {
194194
template <typename F>
195195
void run_(F&& f) noexcept {
196196
const frame_ frame(*this);
197-
try {
197+
STDEXEC_TRY {
198198
static_cast<F&&>(f)();
199-
} catch (...) {
199+
}
200+
STDEXEC_CATCH_ALL {
200201
STDEXEC_ASSERT(frame);
201202
// Do not overwrite the first exception encountered
202203
if (!ex_) {
@@ -255,10 +256,11 @@ namespace asioexec {
255256
if (self_->ex_) {
256257
::stdexec::set_error(static_cast<Receiver&&>(self_->r_), std::move(self_->ex_));
257258
} else {
258-
try {
259+
STDEXEC_TRY {
259260
completion_token::set_value<Signatures>(
260261
static_cast<Receiver&&>(self_->r_), static_cast<Args&&>(args)...);
261-
} catch (...) {
262+
}
263+
STDEXEC_CATCH_ALL {
262264
::stdexec::set_error(static_cast<Receiver&&>(self_->r_), std::current_exception());
263265
}
264266
}
@@ -299,7 +301,7 @@ namespace asioexec {
299301

300302
void start() & noexcept {
301303
const typename base_::frame_ frame(*this);
302-
try {
304+
STDEXEC_TRY {
303305
std::apply(
304306
[&](auto&&... args) {
305307
std::invoke(
@@ -308,7 +310,8 @@ namespace asioexec {
308310
static_cast<decltype(args)&&>(args)...);
309311
},
310312
std::move(args_));
311-
} catch (...) {
313+
}
314+
STDEXEC_CATCH_ALL {
312315
if (!base_::ex_) {
313316
base_::ex_ = std::current_exception();
314317
}

include/asioexec/use_sender.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ namespace asioexec {
3939
std::exception_ptr to_exception_ptr(T t) noexcept {
4040
using exception_type =
4141
std::conditional_t<std::is_same_v<T, std::error_code>, std::system_error, system_error>;
42-
try {
42+
STDEXEC_TRY {
4343
return std::make_exception_ptr(exception_type(static_cast<T&&>(t)));
44-
} catch (...) {
44+
}
45+
STDEXEC_CATCH_ALL {
4546
return std::current_exception();
4647
}
4748
}

include/exec/__detail/__system_context_default_impl.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,13 @@ namespace exec::__system_context_default_impl {
238238

239239
public:
240240
void schedule(std::span<std::byte> __storage, receiver& __r) noexcept override {
241-
try {
241+
STDEXEC_TRY {
242242
auto __sndr = stdexec::schedule(__pool_scheduler_);
243243
auto __os =
244244
__schedule_operation_t::__construct_maybe_alloc(__storage, &__r, std::move(__sndr));
245245
__os->start();
246-
} catch (std::exception& __e) {
246+
}
247+
STDEXEC_CATCH(std::exception & __e) {
247248
__r.set_error(std::current_exception());
248249
}
249250
}
@@ -252,7 +253,7 @@ namespace exec::__system_context_default_impl {
252253
uint32_t __size,
253254
std::span<std::byte> __storage,
254255
bulk_item_receiver& __r) noexcept override {
255-
try {
256+
STDEXEC_TRY {
256257
// Determine the chunking size based on the ratio between the given size and the number of workers in our pool.
257258
// Aim at having 2 chunks per worker.
258259
uint32_t __chunk_size = (__available_parallelism_ > 0
@@ -271,7 +272,8 @@ namespace exec::__system_context_default_impl {
271272
auto __os = __schedule_bulk_chunked_operation_t::__construct_maybe_alloc(
272273
__storage, &__r, std::move(__sndr));
273274
__os->start();
274-
} catch (std::exception& __e) {
275+
}
276+
STDEXEC_CATCH(std::exception & __e) {
275277
__r.set_error(std::current_exception());
276278
}
277279
}
@@ -280,7 +282,7 @@ namespace exec::__system_context_default_impl {
280282
uint32_t __size,
281283
std::span<std::byte> __storage,
282284
bulk_item_receiver& __r) noexcept override {
283-
try {
285+
STDEXEC_TRY {
284286
auto __sndr = stdexec::bulk(
285287
stdexec::schedule(__pool_scheduler_),
286288
stdexec::par,
@@ -289,7 +291,8 @@ namespace exec::__system_context_default_impl {
289291
auto __os = __schedule_bulk_unchunked_operation_t::__construct_maybe_alloc(
290292
__storage, &__r, std::move(__sndr));
291293
__os->start();
292-
} catch (std::exception& __e) {
294+
}
295+
STDEXEC_CATCH(std::exception & __e) {
293296
__r.set_error(std::current_exception());
294297
}
295298
}

0 commit comments

Comments
 (0)