CVB++ 15.0
StreamHandlerGuard< STREAMTYPE > Class Template Referencefinal

Handler guard object to safely run and finish stream handlers. More...

#include <cvb/async/stream_handler_base.hpp>

Public Types

using StreamHandlerBasePtr = std::shared_ptr<StreamHandlerBase<STREAMTYPE>>
 Shared pointer of the stream handler.
 

Public Member Functions

 StreamHandlerGuard (StreamHandlerBasePtr streamHandler, AutoRun autoRun=AutoRun::No) noexcept
 Creates a stream handler guard object.
 
 ~StreamHandlerGuard ()
 Finishes the shared stream handler .
 

Detailed Description

template<class STREAMTYPE>
class Cvb::StreamHandlerGuard< STREAMTYPE >

Handler guard object to safely run and finish stream handlers.

Template Parameters
STREAMTYPEType of stream to be taken care of.

This guard class provides a way to safely stop the stream when leaving the scope (e.g an exception occurs).

Constructor & Destructor Documentation

◆ StreamHandlerGuard()

template<class STREAMTYPE>
StreamHandlerGuard ( StreamHandlerBasePtr streamHandler,
AutoRun autoRun = AutoRun::No )
inlineexplicitnoexcept

Creates a stream handler guard object.

Parameters
[in]streamHandlerStream handler shared by the guard.
[in]autoRunRun the stream handler if yes and not already running, otherwise do nothing.
Exceptions
Doesnot throw any exception.

◆ ~StreamHandlerGuard()

template<class STREAMTYPE>
~StreamHandlerGuard ( )
inline

Finishes the shared stream handler .

Exceptions
Doesnot throw any exception.

All errors occurred within the acquisition thread are shallowed.