#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) | |
~ACE_Errno_Guard (void) | |
Reset the value of errno to <error>. | |
int | operator= (int error) |
Assign <error> 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 &) | |
ACE_Errno_Guard & | operator= (const ACE_Errno_Guard &) |
Private Attributes | |
int | error_ |
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.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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 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 errno
into <error_> and initialize the <errno_ptr_> to the address of <errno_ref>.
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 errno
to <error>.
Definition at line 32 of file OS_Errno.inl.
References error_.
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] |
ACE_INLINE bool ACE_Errno_Guard::operator!= | ( | int | error | ) |
Compare <error> with <error_> for inequality.
Definition at line 62 of file OS_Errno.inl.
References error_.
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 <error> to <error_>.
Definition at line 50 of file OS_Errno.inl.
References error_.
00051 { 00052 return this->error_ = error; 00053 }
ACE_INLINE bool ACE_Errno_Guard::operator== | ( | int | error | ) |
Compare <error> with <error_> for equality.
Definition at line 56 of file OS_Errno.inl.
References error_.
00057 { 00058 return this->error_ == error; 00059 }
int ACE_Errno_Guard::error_ [private] |
Definition at line 83 of file OS_Errno.h.
Referenced by operator!=(), operator=(), operator==(), and ~ACE_Errno_Guard().