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>

List of all members.

Public Member Functions

 ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref, int error)
 ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref)
 ~ACE_Errno_Guard (void)
 Reset the value of to .

int operator= (int error)
 Assign to .

bool operator== (int error)
 Compare with for equality.

bool operator!= (int error)
 Compare with for inequality.


Private Member Functions

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

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.

Definition at line 46 of file OS_Errno.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Errno_Guard::ACE_Errno_Guard ACE_ERRNO_TYPE &  errno_ref,
int  error
 

Stash the value of into and initialize the to the address of .

Definition at line 8 of file OS_Errno.inl.

00010   :
00011 #if defined (ACE_MT_SAFE)
00012     errno_ptr_ (&errno_ref),
00013 #endif /* ACE_MT_SAFE */
00014     error_ (error)
00015 {
00016 #if !defined(ACE_MT_SAFE)
00017   ACE_UNUSED_ARG (errno_ref);
00018 #endif /* ACE_MT_SAFE */
00019 }

ACE_INLINE ACE_Errno_Guard::ACE_Errno_Guard ACE_ERRNO_TYPE &  errno_ref  ) 
 

Stash the value of into and initialize the to the address of .

Definition at line 22 of file OS_Errno.inl.

00023   :
00024 #if defined (ACE_MT_SAFE)
00025     errno_ptr_ (&errno_ref),
00026 #endif /* ACE_MT_SAFE */
00027     error_ (errno_ref)
00028 {
00029 }

ACE_INLINE ACE_Errno_Guard::~ACE_Errno_Guard void   ) 
 

Reset the value of to .

Definition at line 32 of file OS_Errno.inl.

00033 {
00034 #if defined (ACE_MT_SAFE)
00035   *errno_ptr_ = this->error_;
00036 #else
00037   errno = this->error_;
00038 #endif /* ACE_MT_SAFE */
00039 }

ACE_Errno_Guard::ACE_Errno_Guard const ACE_Errno_Guard  )  [private]
 


Member Function Documentation

ACE_INLINE bool ACE_Errno_Guard::operator!= int  error  ) 
 

Compare with for inequality.

Definition at line 62 of file OS_Errno.inl.

00063 {
00064   return this->error_ != error;
00065 }

ACE_Errno_Guard& ACE_Errno_Guard::operator= const ACE_Errno_Guard  )  [private]
 

ACE_INLINE int ACE_Errno_Guard::operator= int  error  ) 
 

Assign to .

Definition at line 50 of file OS_Errno.inl.

00051 {
00052   return this->error_ = error;
00053 }

ACE_INLINE bool ACE_Errno_Guard::operator== int  error  ) 
 

Compare with for equality.

Definition at line 56 of file OS_Errno.inl.

00057 {
00058   return this->error_ == error;
00059 }


Member Data Documentation

int ACE_Errno_Guard::error_ [private]
 

Definition at line 83 of file OS_Errno.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:22:02 2006 for ACE by doxygen 1.3.6