MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::thread::SendOptionNoCallback< S > Struct Template Reference

Select option to send a message without calling a callback on send. More...

#include <select.hpp>

Collaboration diagram for mtcore::thread::SendOptionNoCallback< S >:

Public Types

using Message = typename S::Message
 

Public Member Functions

Result< void, SelectOptionErrorsattempt ()
 
bool prevents_deadlock () const noexcept
 Checks if option is still valid (invalidates on channel close)
 

Public Attributes

S & channel
 
Message m
 
bool valid = true
 

Detailed Description

template<Sender S>
struct mtcore::thread::SendOptionNoCallback< S >

Select option to send a message without calling a callback on send.

Template Parameters
SSender to wait on

Definition at line 80 of file select.hpp.

Member Typedef Documentation

◆ Message

template<Sender S>
using mtcore::thread::SendOptionNoCallback< S >::Message = typename S::Message

Definition at line 81 of file select.hpp.

Member Function Documentation

◆ attempt()

template<Sender S>
Result< void, SelectOptionErrors > mtcore::thread::SendOptionNoCallback< S >::attempt ( )
inline

Definition at line 86 of file select.hpp.

86 {
87 auto res = channel.try_send(m);
88 if (res.is_success()) {
89 return success();
90 }
91 auto err = res.error().code;
92 if constexpr (has_closed_error<std::remove_const_t<decltype(err)>>) {
93 if (err == decltype(err)::CHANNEL_CLOSED) {
94 valid = false;
96 }
97 }
99 }
Success< void > success()
Creates a successful void Result object.
Definition result.hpp:398
Error< Underlying > error(Underlying err)
Creates an error.
Definition result.hpp:425
Select option to send a message without calling a callback on send.
Definition select.hpp:80
Here is the call graph for this function:

◆ prevents_deadlock()

template<Sender S>
bool mtcore::thread::SendOptionNoCallback< S >::prevents_deadlock ( ) const
inlinenodiscardnoexcept

Checks if option is still valid (invalidates on channel close)

Definition at line 102 of file select.hpp.

102{ return valid; }

Member Data Documentation

◆ channel

template<Sender S>
S& mtcore::thread::SendOptionNoCallback< S >::channel

Definition at line 82 of file select.hpp.

◆ m

template<Sender S>
Message mtcore::thread::SendOptionNoCallback< S >::m

Definition at line 83 of file select.hpp.

◆ valid

template<Sender S>
bool mtcore::thread::SendOptionNoCallback< S >::valid = true

Definition at line 84 of file select.hpp.


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