Public Member Functions | Private Types | Private Attributes

ACE_Sig_Adapter Class Reference

Provide an adapter that transforms various types of signal handlers into the scheme used by the ACE_Reactor. More...

#include <Sig_Adapter.h>

Inheritance diagram for ACE_Sig_Adapter:
Inheritance graph
[legend]
Collaboration diagram for ACE_Sig_Adapter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACE_Sig_Adapter (ACE_Sig_Action &, int sigkey)
 ACE_Sig_Adapter (ACE_Event_Handler *, int sigkey)
 ACE_Sig_Adapter (ACE_Sig_Handler_Ex, int sigkey=0)
 ~ACE_Sig_Adapter (void)
int sigkey (void)
virtual int handle_signal (int, siginfo_t *, ucontext_t *)
 Called by the <Reactor> to dispatch the signal handler.

Private Types

enum  { ACE_HANDLER, SIG_ACTION, C_FUNCTION }
 

Is this an external handler or an ACE handler?

More...

Private Attributes

int sigkey_
 Key for this signal handler (used to remove it).
enum ACE_Sig_Adapter:: { ... }  type_
 Is this an external handler or an ACE handler?
ACE_Sig_Action sa_
 This is an external handler (ugh).
ACE_Event_Handlereh_
 This is an ACE hander.
ACE_Sig_Handler_Ex sig_func_
 This is a normal C function.

Detailed Description

Provide an adapter that transforms various types of signal handlers into the scheme used by the ACE_Reactor.

Definition at line 35 of file Sig_Adapter.h.


Member Enumeration Documentation

anonymous enum [private]

Is this an external handler or an ACE handler?

Enumerator:
ACE_HANDLER 

We're just wrapping an ACE_Event_Handler.

SIG_ACTION 

An ACE_Sig_Action.

C_FUNCTION 

A normal C function.

Definition at line 55 of file Sig_Adapter.h.

  {
    /// We're just wrapping an ACE_Event_Handler.
    ACE_HANDLER,
    /// An ACE_Sig_Action.
    SIG_ACTION,
    /// A normal C function.
    C_FUNCTION
  } type_;


Constructor & Destructor Documentation

ACE_Sig_Adapter::ACE_Sig_Adapter ( ACE_Sig_Action sa,
int  sigkey 
)

Definition at line 8 of file Sig_Adapter.cpp.

  : sigkey_ (sigkey),
    type_ (SIG_ACTION),
    sa_ (sa)
{
  // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter");
}

ACE_Sig_Adapter::ACE_Sig_Adapter ( ACE_Event_Handler eh,
int  sigkey 
)

Definition at line 16 of file Sig_Adapter.cpp.

  : sigkey_ (sigkey),
    type_ (ACE_HANDLER),
    eh_ (eh)
{
  // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter");
}

ACE_Sig_Adapter::ACE_Sig_Adapter ( ACE_Sig_Handler_Ex  sig_func,
int  sigkey = 0 
)

Definition at line 25 of file Sig_Adapter.cpp.

  : sigkey_ (sigkey),
    type_ (C_FUNCTION),
    sig_func_ (sig_func)
{
  // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter");
}

ACE_Sig_Adapter::~ACE_Sig_Adapter ( void   ) 

Definition at line 34 of file Sig_Adapter.cpp.

{
}


Member Function Documentation

int ACE_Sig_Adapter::handle_signal ( int  signum,
siginfo_t siginfo,
ucontext_t ucontext 
) [virtual]

Called by the <Reactor> to dispatch the signal handler.

Reimplemented from ACE_Event_Handler.

Definition at line 46 of file Sig_Adapter.cpp.

{
  ACE_TRACE ("ACE_Sig_Adapter::handle_signal");

  switch (this->type_)
    {
    case SIG_ACTION:
      {
        // We have to dispatch a handler that was registered by a
        // third-party library.

        ACE_Sig_Action old_disp;

        // Make sure this handler executes in the context it was
        // expecting...
        this->sa_.register_action (signum, &old_disp);

        ACE_Sig_Handler_Ex sig_func = ACE_Sig_Handler_Ex (this->sa_.handler ());

        (*sig_func) (signum, siginfo, ucontext);
        // Restore the original disposition.
        old_disp.register_action (signum);
        break;
      }
    case ACE_HANDLER:
      this->eh_->handle_signal (signum, siginfo, ucontext);
      break;
    case C_FUNCTION:
      (*this->sig_func_) (signum, siginfo, ucontext);
      break;
    }
  return 0;
}

int ACE_Sig_Adapter::sigkey ( void   ) 

Returns this signal key that's used to remove this from the ACE_Reactor's internal table.

Definition at line 39 of file Sig_Adapter.cpp.

{
  ACE_TRACE ("ACE_Sig_Adapter::sigkey");
  return this->sigkey_;
}


Member Data Documentation

This is an ACE hander.

Definition at line 71 of file Sig_Adapter.h.

This is an external handler (ugh).

Definition at line 68 of file Sig_Adapter.h.

This is a normal C function.

Definition at line 74 of file Sig_Adapter.h.

int ACE_Sig_Adapter::sigkey_ [private]

Key for this signal handler (used to remove it).

Definition at line 52 of file Sig_Adapter.h.

enum { ... } ACE_Sig_Adapter::type_ [private]

Is this an external handler or an ACE handler?


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