MCPcopy Create free account
hub / github.com/NVIDIA/stdexec / __complete_

Method __complete_

include/exec/async_scope.hpp:310–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308 stop_callback_for_t<stop_token_of_t<env_of_t<_Receiver>>, __forward_stopped>;
309
310 constexpr void __complete_() noexcept
311 {
312 STDEXEC_TRY
313 {
314 __forward_consumer_.reset();
315 auto __state = std::move(__state_);
316 STDEXEC_ASSERT(__state != nullptr);
317 std::unique_lock __guard{__state->__mutex_};
318 // either the future is still in use or it has passed ownership to __state->__no_future_
319 if (__state->__no_future_.get() != nullptr || __state->__step_ != __future_step::__future)
320 {
321 // invalid state - there is a code bug in the state machine
322 std::terminate();
323 }
324 else if (get_stop_token(get_env(__rcvr_)).stop_requested())
325 {
326 __guard.unlock();
327 STDEXEC::set_stopped(static_cast<_Receiver&&>(__rcvr_));
328 __guard.lock();
329 }
330 else
331 {
332 std::visit(
333 [this, &__guard]<class _Tup>(_Tup& __tup)
334 {
335 if constexpr (__std::same_as<_Tup, std::monostate>)
336 {
337 std::terminate();
338 }
339 else
340 {
341 std::apply(
342 [this, &__guard]<class... _As>(auto tag, _As&... __as)
343 {
344 __guard.unlock();
345 tag(static_cast<_Receiver&&>(__rcvr_), static_cast<_As&&>(__as)...);
346 __guard.lock();
347 },
348 __tup);
349 }
350 },
351 __state->__data_);
352 }
353 }
354 STDEXEC_CATCH_ALL
355 {
356 STDEXEC::set_error(static_cast<_Receiver&&>(__rcvr_), std::current_exception());

Callers 1

async_scope.hppFile · 0.45

Calls 6

get_envFunction · 0.70
set_stoppedFunction · 0.70
applyFunction · 0.70
resetMethod · 0.45
getMethod · 0.45
stop_requestedMethod · 0.45

Tested by

no test coverage detected