ACE_Sig_Guard Class Reference

Hold signals in MASK for duration of a C++ statement block. Note that a "0" for mask causes all signals to be held. More...

#include <Signal.h>

Collaboration diagram for ACE_Sig_Guard:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Sig_Guard (ACE_Sig_Set *mask=0, bool condition=true)
 ~ACE_Sig_Guard (void)
 Restore blocked signals.
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Attributes

ACE_Sig_Set omask_
 Original signal mask.
bool condition_
 Guard Condition.

Detailed Description

Hold signals in MASK for duration of a C++ statement block. Note that a "0" for mask causes all signals to be held.

Definition at line 234 of file Signal.h.


Constructor & Destructor Documentation

ACE_INLINE ACE_Sig_Guard::ACE_Sig_Guard ( ACE_Sig_Set mask = 0,
bool  condition = true 
)

This is kind of conditional Guard, needed when guard should be activated only when a spcific condition met. When condition == true (default), Guard is activated

Definition at line 225 of file Signal.inl.

References ACE_OS_Object_Manager::default_mask(), SIG_BLOCK, ACE_OS::sigprocmask(), and ACE_OS::thr_sigsetmask().

00227   : omask_ ()
00228   , condition_ (condition)
00229 {
00230   //ACE_TRACE ("ACE_Sig_Guard::ACE_Sig_Guard");
00231   if (!this->condition_)
00232     return;
00233 
00234 #if defined (ACE_LACKS_UNIX_SIGNALS)
00235   ACE_UNUSED_ARG (mask);
00236 #else
00237   // If MASK is 0 then block all signals!
00238   if (mask == 0)
00239     {
00240 #  if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
00241       ACE_OS::sigprocmask (SIG_BLOCK,
00242                            ACE_OS_Object_Manager::default_mask (),
00243                            (sigset_t *) this->omask_);
00244 #  else
00245       ACE_OS::thr_sigsetmask (SIG_BLOCK,
00246                               ACE_OS_Object_Manager::default_mask (),
00247                               (sigset_t *) this->omask_);
00248 #  endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
00249     }
00250   else
00251 #  if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
00252     ACE_OS::sigprocmask (SIG_BLOCK,
00253                          (sigset_t *) *mask,
00254                          (sigset_t *)
00255                          this->omask_);
00256 #  else
00257     ACE_OS::thr_sigsetmask (SIG_BLOCK,
00258                             (sigset_t *) *mask,
00259                             (sigset_t *)
00260                             this->omask_);
00261 #  endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
00262 #endif /* ACE_LACKS_UNIX_SIGNALS */
00263 }

ACE_Sig_Guard::~ACE_Sig_Guard ( void   ) 

Restore blocked signals.

Definition at line 40 of file Signal.cpp.

References SIG_SETMASK, ACE_OS::sigprocmask(), and ACE_OS::thr_sigsetmask().

00041 {
00042   //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard");
00043   if (!this->condition_)
00044     return;
00045 
00046 #if !defined (ACE_LACKS_UNIX_SIGNALS)
00047 #if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
00048   ACE_OS::sigprocmask (SIG_SETMASK,
00049                        (sigset_t *) this->omask_,
00050                        0);
00051 #else
00052   ACE_OS::thr_sigsetmask (SIG_SETMASK,
00053                           (sigset_t *) this->omask_,
00054                           0);
00055 #endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
00056 #endif /* !ACE_LACKS_UNIX_SIGNALS */
00057 }


Member Function Documentation

void ACE_Sig_Guard::dump ( void   )  const

Dump the state of an object.

Definition at line 70 of file Signal.cpp.

References ACE_TRACE.

00071 {
00072 #if defined (ACE_HAS_DUMP)
00073   ACE_TRACE ("ACE_Sig_Guard::dump");
00074 #endif /* ACE_HAS_DUMP */
00075 }


Member Data Documentation

ACE_Sig_Guard::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Definition at line 250 of file Signal.h.

bool ACE_Sig_Guard::condition_ [private]

Guard Condition.

Definition at line 257 of file Signal.h.

ACE_Sig_Set ACE_Sig_Guard::omask_ [private]

Original signal mask.

Definition at line 254 of file Signal.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:36 2010 for ACE by  doxygen 1.4.7