Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

 ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref, int error)
 Stash the value of <error> into <error_> and initialize the <errno_ptr_> to the address of <errno_ref>. More...

 ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref)
 Stash the value of <errno> into <error_> and initialize the <errno_ptr_> to the address of <errno_ref>. More...

 ~ACE_Errno_Guard (void)
 Reset the value of <errno> to <error>. More...

int operator= (int error)
 Assign <error> to <error_>. More...

int operator== (int error)
 Compare <error> with <error_> for equality. More...

int operator!= (int error)
 Compare <error> with <error_> for inequality. More...


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 97 of file OS_Errno.h.


Constructor & Destructor Documentation

ACE_INLINE ACE_Errno_Guard::ACE_Errno_Guard ACE_ERRNO_TYPE &    errno_ref,
int    error
 

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

Definition at line 30 of file OS_Errno.inl.

References ACE_ERRNO_TYPE.

00032   :
00033 #if defined (ACE_MT_SAFE)
00034     errno_ptr_ (&errno_ref),
00035 #endif /* ACE_MT_SAFE */
00036     error_ (error)
00037 {
00038 #if !defined(ACE_MT_SAFE)
00039   ACE_UNUSED_ARG (errno_ref);
00040 #endif /* ACE_MT_SAFE */
00041 }

ACE_INLINE ACE_Errno_Guard::ACE_Errno_Guard ACE_ERRNO_TYPE &    errno_ref
 

Stash the value of <errno> into <error_> and initialize the <errno_ptr_> to the address of <errno_ref>.

Definition at line 44 of file OS_Errno.inl.

References ACE_ERRNO_TYPE.

00045   :
00046 #if defined (ACE_MT_SAFE)
00047     errno_ptr_ (&errno_ref),
00048 #endif /* ACE_MT_SAFE */
00049     error_ (errno_ref)
00050 {
00051 }

ACE_INLINE ACE_Errno_Guard::~ACE_Errno_Guard void   
 

Reset the value of <errno> to <error>.

Definition at line 54 of file OS_Errno.inl.

References error_.

00055 {
00056 #if defined (ACE_MT_SAFE)
00057   *errno_ptr_ = this->error_;
00058 #else
00059   errno = this->error_;
00060 #endif /* ACE_MT_SAFE */
00061 }


Member Function Documentation

ACE_INLINE int ACE_Errno_Guard::operator!= int    error
 

Compare <error> with <error_> for inequality.

Definition at line 84 of file OS_Errno.inl.

References error_.

00085 {
00086   return this->error_ != error;
00087 }

ACE_INLINE int ACE_Errno_Guard::operator= int    error
 

Assign <error> to <error_>.

Definition at line 72 of file OS_Errno.inl.

References error_.

00073 {
00074   return this->error_ = error;
00075 }

ACE_INLINE int ACE_Errno_Guard::operator== int    error
 

Compare <error> with <error_> for equality.

Definition at line 78 of file OS_Errno.inl.

References error_.

00079 {
00080   return this->error_ == error;
00081 }


Member Data Documentation

int ACE_Errno_Guard::error_ [private]
 

Definition at line 130 of file OS_Errno.h.

Referenced by operator!=, operator=, operator==, and ~ACE_Errno_Guard.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:40 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002