Public Member Functions | List of all members
rapidsmpf::streaming::ShutdownAtExit Class Reference

Helper RAII class to shut down channels when they go out of scope. More...

#include <channel.hpp>

Public Member Functions

 ShutdownAtExit (std::vector< std::shared_ptr< Channel >> channels)
 Construct from a vector of channel handles. More...
 
template<class... T>
 ShutdownAtExit (T &&... channels) requires(std
 Variadic convenience constructor. More...
 
 ShutdownAtExit (ShutdownAtExit const &)=delete
 
ShutdownAtExitoperator= (ShutdownAtExit const &)=delete
 
 ShutdownAtExit (ShutdownAtExit &&)=delete
 
ShutdownAtExitoperator= (ShutdownAtExit &&)=delete
 
 ~ShutdownAtExit () noexcept
 Destructor that synchronously shuts down all channels. More...
 

Detailed Description

Helper RAII class to shut down channels when they go out of scope.

When this object is destroyed, it invokes shutdown() on all provided channels in the order they were provided. After shutdown, any pending or future send/receive operations on those channels will fail or yield nullopt.

This is useful inside coroutine bodies to guarantee channels are shut down if an unhandled exception escapes the coroutine. Relying on a channel's own destructor is insufficient when the channel is shared (e.g., via std::shared_ptr), because other owners keep it alive.

Definition at line 262 of file channel.hpp.

Constructor & Destructor Documentation

◆ ShutdownAtExit() [1/2]

rapidsmpf::streaming::ShutdownAtExit::ShutdownAtExit ( std::vector< std::shared_ptr< Channel >>  channels)
inlineexplicit

Construct from a vector of channel handles.

The order of elements determines the shutdown order invoked by the destructor.

Parameters
channelsVector of shared channel handles to be shut down on destruction.
Exceptions
std::invalid_argumentIf any channel in the vector is nullptr.

Definition at line 273 of file channel.hpp.

◆ ShutdownAtExit() [2/2]

template<class... T>
rapidsmpf::streaming::ShutdownAtExit::ShutdownAtExit ( T &&...  channels)
inlineexplicit

Variadic convenience constructor.

Enables ShutdownAtExit{ch1, ch2, ...} without explicitly creating a vector. Each argument must be convertible to std::shared_ptr<Channel>. The order of the arguments determines the shutdown order in the destructor.

Template Parameters
TParameter pack of types convertible to std::shared_ptr<Channel>.
Parameters
channelsOne or more channel handles.
Exceptions
std::invalid_argumentIf any of the provided channel pointers is nullptr.

Definition at line 293 of file channel.hpp.

◆ ~ShutdownAtExit()

rapidsmpf::streaming::ShutdownAtExit::~ShutdownAtExit ( )
inlinenoexcept

Destructor that synchronously shuts down all channels.

Calls shutdown() on each channel in the same order they were passed.

Definition at line 310 of file channel.hpp.


The documentation for this class was generated from the following file: