*Backed out changeset 3be01fb200a5
--HG-- branch : trunk
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/* -*- C++ -*- */
|
||||
|
||||
//==========================================================================
|
||||
/**
|
||||
* @file Event_Handler.h
|
||||
@@ -8,24 +9,32 @@
|
||||
* @author Douglas C. Schmidt <[email protected]>
|
||||
*/
|
||||
//==========================================================================
|
||||
|
||||
#ifndef ACE_EVENT_HANDLER_H
|
||||
#define ACE_EVENT_HANDLER_H
|
||||
#include /**/ "ace/pre.h"
|
||||
|
||||
#include /**/ "ace/ACE_export.h"
|
||||
|
||||
#if !defined (ACE_LACKS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif /* ACE_LACKS_PRAGMA_ONCE */
|
||||
|
||||
#include "ace/os_include/os_signal.h"
|
||||
#include "ace/Atomic_Op.h"
|
||||
#include "ace/Synch_Traits.h"
|
||||
|
||||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
// Forward declaration.
|
||||
class ACE_Message_Block;
|
||||
class ACE_Reactor;
|
||||
class ACE_Reactor_Timer_Interface;
|
||||
class ACE_Thread_Manager;
|
||||
class ACE_Process;
|
||||
|
||||
typedef unsigned long ACE_Reactor_Mask;
|
||||
|
||||
/**
|
||||
* @class ACE_Event_Handler
|
||||
*
|
||||
@@ -73,26 +82,36 @@ public:
|
||||
EXCEPT_MASK,
|
||||
DONT_CALL = (1 << 9)
|
||||
};
|
||||
|
||||
/// Destructor is virtual to enable proper cleanup.
|
||||
virtual ~ACE_Event_Handler (void);
|
||||
|
||||
/// Get the I/O handle.
|
||||
virtual ACE_HANDLE get_handle (void) const;
|
||||
|
||||
/// Set the I/O handle.
|
||||
virtual void set_handle (ACE_HANDLE);
|
||||
|
||||
// = Get/set priority
|
||||
|
||||
// Priorities run from MIN_PRIORITY (which is the "lowest priority")
|
||||
// to MAX_PRIORITY (which is the "highest priority").
|
||||
/// Get the priority of the Event_Handler.
|
||||
virtual int priority (void) const;
|
||||
|
||||
/// Set the priority of the Event_Handler.
|
||||
virtual void priority (int priority);
|
||||
|
||||
/// Called when input events occur (e.g., connection or data).
|
||||
virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE);
|
||||
|
||||
/// Called when output events are possible (e.g., when flow control
|
||||
/// abates or non-blocking connection completes).
|
||||
virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE);
|
||||
|
||||
/// Called when an exceptional events occur (e.g., SIGURG).
|
||||
virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* Called when timer expires. @a current_time represents the current
|
||||
* time that the <Event_Handler> was selected for timeout
|
||||
@@ -101,17 +120,21 @@ public:
|
||||
*/
|
||||
virtual int handle_timeout (const ACE_Time_Value ¤t_time,
|
||||
const void *act = 0);
|
||||
|
||||
/// Called when a process exits.
|
||||
virtual int handle_exit (ACE_Process *);
|
||||
|
||||
/// Called when a <handle_*()> method returns -1 or when the
|
||||
/// <remove_handler> method is called on an ACE_Reactor. The
|
||||
/// @a close_mask indicates which event has triggered the
|
||||
/// <handle_close> method callback on a particular @a handle.
|
||||
virtual int handle_close (ACE_HANDLE handle,
|
||||
ACE_Reactor_Mask close_mask);
|
||||
|
||||
/// Called when object is signaled by OS (either via UNIX signals or
|
||||
/// when a Win32 object becomes signaled).
|
||||
virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0);
|
||||
|
||||
enum
|
||||
{
|
||||
/// The handler is not resumed at all. Could lead to deadlock..
|
||||
@@ -135,15 +158,20 @@ public:
|
||||
* be used across different components in ACE.
|
||||
*/
|
||||
virtual int resume_handler (void);
|
||||
|
||||
virtual int handle_qos (ACE_HANDLE = ACE_INVALID_HANDLE);
|
||||
virtual int handle_group_qos (ACE_HANDLE = ACE_INVALID_HANDLE);
|
||||
|
||||
// = Accessors to set/get the various event demultiplexors.
|
||||
/// Set the event demultiplexors.
|
||||
virtual void reactor (ACE_Reactor *reactor);
|
||||
|
||||
/// Get the event demultiplexors.
|
||||
virtual ACE_Reactor *reactor (void) const;
|
||||
|
||||
/// Get only the reactor's timer related interface.
|
||||
virtual ACE_Reactor_Timer_Interface *reactor_timer_interface (void) const;
|
||||
|
||||
/**
|
||||
* Used to read from non-socket ACE_HANDLEs in our own thread to
|
||||
* work around Win32 limitations that don't allow us to <select> on
|
||||
@@ -155,6 +183,7 @@ public:
|
||||
* reading from ACE_STDIN.
|
||||
*/
|
||||
static ACE_THR_FUNC_RETURN read_adapter (void *event_handler);
|
||||
|
||||
/**
|
||||
* Abstracts away from the differences between Win32 and ACE with
|
||||
* respect to reading from ACE_STDIN, which is non-<select>'able on
|
||||
@@ -164,11 +193,14 @@ public:
|
||||
ACE_Reactor *reactor,
|
||||
ACE_Thread_Manager *thr_mgr,
|
||||
int flags = THR_DETACHED);
|
||||
|
||||
/// Performs the inverse of the <register_stdin_handler> method.
|
||||
static int remove_stdin_handler (ACE_Reactor *reactor,
|
||||
ACE_Thread_Manager *thr_mgr);
|
||||
|
||||
/// Reference count type.
|
||||
typedef long Reference_Count;
|
||||
|
||||
/// Increment reference count on the handler.
|
||||
/**
|
||||
* This method is called when the handler is registered with the
|
||||
@@ -178,6 +210,7 @@ public:
|
||||
* @return Current reference count.
|
||||
*/
|
||||
virtual Reference_Count add_reference (void);
|
||||
|
||||
/// Decrement reference count on the handler.
|
||||
/**
|
||||
* This method is called when the handler is removed from the
|
||||
@@ -188,6 +221,7 @@ public:
|
||||
* @return Current reference count.
|
||||
*/
|
||||
virtual Reference_Count remove_reference (void);
|
||||
|
||||
/**
|
||||
* @class Policy
|
||||
*
|
||||
@@ -195,10 +229,13 @@ public:
|
||||
*/
|
||||
class ACE_Export Policy
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/// Virtual destructor.
|
||||
virtual ~Policy (void);
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Reference_Counting_Policy
|
||||
*
|
||||
@@ -215,7 +252,9 @@ public:
|
||||
{
|
||||
/// This policy can only be created by the handler.
|
||||
friend class ACE_Event_Handler;
|
||||
|
||||
public:
|
||||
|
||||
enum Value
|
||||
{
|
||||
/// Perform reference counting.
|
||||
@@ -223,34 +262,48 @@ public:
|
||||
/// Don't perform reference counting.
|
||||
DISABLED
|
||||
};
|
||||
|
||||
/// Current Reference_Counting_Policy.
|
||||
Value value (void) const;
|
||||
|
||||
/// Update Reference_Counting_Policy.
|
||||
void value (Value value);
|
||||
|
||||
private:
|
||||
|
||||
/// Private constructor.
|
||||
Reference_Counting_Policy (Value value);
|
||||
|
||||
/// The value of the policy.
|
||||
Value value_;
|
||||
};
|
||||
|
||||
/// Current Reference_Counting_Policy.
|
||||
Reference_Counting_Policy &reference_counting_policy (void);
|
||||
|
||||
protected:
|
||||
/// Force ACE_Event_Handler to be an abstract base class.
|
||||
ACE_Event_Handler (ACE_Reactor * = 0,
|
||||
int priority = ACE_Event_Handler::LO_PRIORITY);
|
||||
|
||||
/// Typedef for implementation of reference counting.
|
||||
typedef ACE_Atomic_Op<ACE_SYNCH_MUTEX, Reference_Count> Atomic_Reference_Count;
|
||||
|
||||
/// Reference count.
|
||||
Atomic_Reference_Count reference_count_;
|
||||
|
||||
private:
|
||||
|
||||
/// Priority of this Event_Handler.
|
||||
int priority_;
|
||||
|
||||
/// Pointer to the various event demultiplexors.
|
||||
ACE_Reactor *reactor_;
|
||||
|
||||
/// Reference counting requirements.
|
||||
Reference_Counting_Policy reference_counting_policy_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class ACE_Event_Handler_var
|
||||
*
|
||||
@@ -261,31 +314,45 @@ private:
|
||||
*/
|
||||
class ACE_Export ACE_Event_Handler_var
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/// Default constructor.
|
||||
ACE_Event_Handler_var (void);
|
||||
|
||||
/// Construct with a handler.
|
||||
ACE_Event_Handler_var (ACE_Event_Handler *p);
|
||||
|
||||
/// Copy constructor.
|
||||
ACE_Event_Handler_var (const ACE_Event_Handler_var &b);
|
||||
|
||||
/// Destructor.
|
||||
~ACE_Event_Handler_var (void);
|
||||
|
||||
/// Assignment to a handler.
|
||||
ACE_Event_Handler_var &operator= (ACE_Event_Handler *p);
|
||||
|
||||
/// Assignment to a ACE_Event_Handler_var.
|
||||
ACE_Event_Handler_var &operator= (const ACE_Event_Handler_var &b);
|
||||
|
||||
/// Overloaded "->".
|
||||
ACE_Event_Handler *operator-> () const;
|
||||
|
||||
/// Access the handler.
|
||||
ACE_Event_Handler *handler (void) const;
|
||||
|
||||
/// Release the handler.
|
||||
ACE_Event_Handler *release (void);
|
||||
|
||||
/// Reset the handler.
|
||||
void reset (ACE_Event_Handler *p = 0);
|
||||
|
||||
private:
|
||||
|
||||
/// Handler.
|
||||
ACE_Event_Handler *ptr_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class ACE_Notification_Buffer
|
||||
*
|
||||
@@ -296,20 +363,27 @@ class ACE_Export ACE_Notification_Buffer
|
||||
{
|
||||
public:
|
||||
ACE_Notification_Buffer (void);
|
||||
|
||||
ACE_Notification_Buffer (ACE_Event_Handler *eh,
|
||||
ACE_Reactor_Mask mask);
|
||||
|
||||
/// Default dtor.
|
||||
~ACE_Notification_Buffer (void);
|
||||
|
||||
/// Pointer to the Event_Handler that will be dispatched
|
||||
/// by the main event loop.
|
||||
ACE_Event_Handler *eh_;
|
||||
|
||||
/// Mask that indicates which method to call.
|
||||
ACE_Reactor_Mask mask_;
|
||||
};
|
||||
|
||||
ACE_END_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
#if defined (__ACE_INLINE__)
|
||||
#include "ace/Event_Handler.inl"
|
||||
#endif /* __ACE_INLINE__ */
|
||||
|
||||
#include /**/ "ace/post.h"
|
||||
#endif /* ACE_EVENT_HANDLER_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user