Public Member Functions | Public Attributes | Private Attributes

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_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.

  : omask_ ()
  , condition_ (condition)
{
  //ACE_TRACE ("ACE_Sig_Guard::ACE_Sig_Guard");
  if (!this->condition_)
    return;

#if defined (ACE_LACKS_UNIX_SIGNALS)
  ACE_UNUSED_ARG (mask);
#else
  // If MASK is 0 then block all signals!
  if (mask == 0)
    {
#  if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
      ACE_OS::sigprocmask (SIG_BLOCK,
                           ACE_OS_Object_Manager::default_mask (),
                           (sigset_t *) this->omask_);
#  else
      ACE_OS::thr_sigsetmask (SIG_BLOCK,
                              ACE_OS_Object_Manager::default_mask (),
                              (sigset_t *) this->omask_);
#  endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
    }
  else
#  if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
    ACE_OS::sigprocmask (SIG_BLOCK,
                         (sigset_t *) *mask,
                         (sigset_t *)
                         this->omask_);
#  else
    ACE_OS::thr_sigsetmask (SIG_BLOCK,
                            (sigset_t *) *mask,
                            (sigset_t *)
                            this->omask_);
#  endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
#endif /* ACE_LACKS_UNIX_SIGNALS */
}

ACE_Sig_Guard::~ACE_Sig_Guard ( void   ) 

Restore blocked signals.

Definition at line 40 of file Signal.cpp.

{
  //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard");
  if (!this->condition_)
    return;

#if !defined (ACE_LACKS_UNIX_SIGNALS)
#if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
  ACE_OS::sigprocmask (SIG_SETMASK,
                       (sigset_t *) this->omask_,
                       0);
#else
  ACE_OS::thr_sigsetmask (SIG_SETMASK,
                          (sigset_t *) this->omask_,
                          0);
#endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
#endif /* !ACE_LACKS_UNIX_SIGNALS */
}


Member Function Documentation

void ACE_Sig_Guard::dump ( void   )  const

Dump the state of an object.

Definition at line 70 of file Signal.cpp.

{
#if defined (ACE_HAS_DUMP)
  ACE_TRACE ("ACE_Sig_Guard::dump");
#endif /* ACE_HAS_DUMP */
}


Member Data Documentation

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.

Original signal mask.

Definition at line 254 of file Signal.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines