ACE 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ACE_Errno_Guard Class Reference

Provides a wrapper to improve performance when thread-specific errno must be saved and restored in a block of code. More...

#include <OS_Errno.h>

Public Member Functions

 ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref, int error)
 
 ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref)
 Initialize the errno_ptr_ to the address of errno_ref.
 
 ~ACE_Errno_Guard ()
 Reset the value of errno to <error>.
 
int operator= (int error)
 Assign erro> to error_.
 
bool operator== (int error)
 Compare error with error_ for equality.
 
bool operator!= (int error)
 Compare error with error_ for inequality.
 

Private Member Functions

 ACE_Errno_Guard (const ACE_Errno_Guard &)=delete
 
ACE_Errno_Guardoperator= (const ACE_Errno_Guard &)=delete
 

Private Attributes

int error_
 

Detailed Description

Provides a wrapper to improve performance when thread-specific errno must be saved and restored in a block of code.

The typical use-case for this is the following: int error = errno; call_some_function_that_might_change_errno (); errno = error; This can be replaced with { ACE_Errno_Guard guard (errno); call_some_function_that_might_change_errno (); } This implementation is more elegant and more efficient since it avoids an unnecessary second access to thread-specific storage by caching a pointer to the value of errno in TSS.

Constructor & Destructor Documentation

◆ ACE_Errno_Guard() [1/3]

ACE_Errno_Guard::ACE_Errno_Guard ( ACE_ERRNO_TYPE & errno_ref,
int error )
inline

Stash the value of error into error_ and initialize the errno_ptr_ to the address of errno_ref.

◆ ACE_Errno_Guard() [2/3]

ACE_Errno_Guard::ACE_Errno_Guard ( ACE_ERRNO_TYPE & errno_ref)
inline

Initialize the errno_ptr_ to the address of errno_ref.

◆ ~ACE_Errno_Guard()

ACE_Errno_Guard::~ACE_Errno_Guard ( )
inline

Reset the value of errno to <error>.

◆ ACE_Errno_Guard() [3/3]

ACE_Errno_Guard::ACE_Errno_Guard ( const ACE_Errno_Guard & )
privatedelete

Member Function Documentation

◆ operator!=()

bool ACE_Errno_Guard::operator!= ( int error)
inline

Compare error with error_ for inequality.

◆ operator=() [1/2]

ACE_Errno_Guard & ACE_Errno_Guard::operator= ( const ACE_Errno_Guard & )
privatedelete

◆ operator=() [2/2]

int ACE_Errno_Guard::operator= ( int error)
inline

Assign erro> to error_.

◆ operator==()

bool ACE_Errno_Guard::operator== ( int error)
inline

Compare error with error_ for equality.

Member Data Documentation

◆ error_

int ACE_Errno_Guard::error_
private

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