summaryrefslogtreecommitdiff
path: root/ace/TP_Reactor.h
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2001-08-24 21:23:56 +0000
committerbala <balanatarajan@users.noreply.github.com>2001-08-24 21:23:56 +0000
commita5ca76d4d27526f2905fff8b9bb0f0f297dd68ed (patch)
treeba223c951bf1eba2a7bb5a9e6043a82f3dadf2cf /ace/TP_Reactor.h
parent9be313215bd4606577708f16c7770bbe9913c7d4 (diff)
downloadATCD-a5ca76d4d27526f2905fff8b9bb0f0f297dd68ed.tar.gz
ChangeLogTag: Fri Aug 24 16:10:20 2001 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'ace/TP_Reactor.h')
-rw-r--r--ace/TP_Reactor.h100
1 files changed, 82 insertions, 18 deletions
diff --git a/ace/TP_Reactor.h b/ace/TP_Reactor.h
index 65f85383058..61043e01db2 100644
--- a/ace/TP_Reactor.h
+++ b/ace/TP_Reactor.h
@@ -32,12 +32,13 @@
#include "ace/pre.h"
#include "ace/Select_Reactor.h"
-#include "ace/Log_Msg.h"
+
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
+
/**
* @class ACE_EH_Dispatch_Info
*
@@ -71,6 +72,61 @@ private:
ACE_UNIMPLEMENTED_FUNC (ACE_EH_Dispatch_Info &operator= (const ACE_EH_Dispatch_Info &))
};
+
+/**
+ * @class ACE_TP_Token_Guard
+ *
+ * @brief A helper class that helps grabbing, releasing and waiting
+ * on tokens for a thread that tries calling handle_events ().
+ *
+ * In short, this class will be owned by one thread by creating on the
+ * stack. This class gives the status of the ownership of the token
+ * and manages the ownership
+ */
+
+class ACE_Export ACE_TP_Token_Guard
+{
+public:
+
+ /// Constructor that will grab the token for us
+ ACE_TP_Token_Guard (ACE_Select_Reactor_Token &token,
+ ACE_Time_Value *max_wait_time,
+ int &result);
+
+ /// Destructor. This will release the token if it hasnt been
+ /// released till this point
+ ~ACE_TP_Token_Guard (void);
+
+ /// Release the token ..
+ void release_token (void);
+
+ /// Returns whether the thread that created this object ownes the
+ /// token or not.
+ int is_owner (void);
+
+private:
+
+ /// A helper method that grabs the token for us, after which the
+ /// thread that owns that can do some actual work.
+ int grab_token (ACE_Time_Value *max_wait_time);
+
+private:
+
+ /// The Select Reactor token.
+ ACE_Select_Reactor_Token &token_;
+
+ /// Flag that indicate whether the thread that created this object
+ /// owns the token or not. A value of 0 indicates that this class
+ /// hasnt got the token (and hence the thread) and a value of 1
+ /// vice-versa.
+ int owner_;
+
+private:
+
+ ACE_UNIMPLEMENTED_FUNC (ACE_TP_Token_Guard (void))
+};
+
+
/**
* @class ACE_TP_Reactor
*
@@ -128,6 +184,9 @@ public:
ACE_Timer_Queue * = 0,
int mask_signals = 1);
+ // = Reactor calls
+ virtual void max_notify_iterations (int iter);
+
// = Event loop drivers.
/**
@@ -187,21 +246,23 @@ public:
protected:
// = Internal methods that do the actual work.
- /**
- * Dispatch signal, timer, notification handlers and return possibly
- * 1 I/O handler for dispatching. Ideally, it would dispatch nothing,
- * and return dispatch information for only one of (signal, timer,
- * notification, I/O); however, the reactor mechanism is too enmeshed
- * in the timer queue expiry functions and the notification class to
- * do this without some significant redesign.
- */
- int dispatch_i (ACE_Time_Value *max_wait_time,
- ACE_EH_Dispatch_Info &event);
+ /// Get the event that needs dispatching.It could be either a
+ /// signal, timer, notification handlers or return possibly 1 I/O
+ /// handler for dispatching. In the most common use case, this would
+ /// return 1 I/O handler for dispatching
+ int get_event_for_dispatching (ACE_Time_Value *max_wait_time);
+
+ int handle_signals (int &event_count,
+ ACE_TP_Token_Guard &g);
+
+ int handle_timer_events (int &event_count,
+ ACE_TP_Token_Guard &g);
- int dispatch_i_protected (ACE_Time_Value *max_wait_time,
- /// Only really does anything for Win32. Wraps a call to dispatch_i in an
- /// ACE_SEH_TRY block.
- ACE_EH_Dispatch_Info &event);
+ int handle_notify_events (int &event_count,
+ ACE_TP_Token_Guard &g);
+
+ int handle_socket_events (int &event_count,
+ ACE_TP_Token_Guard &g);
/// This method shouldn't get called.
virtual void notify_handle (ACE_HANDLE handle,
@@ -209,10 +270,13 @@ protected:
ACE_Handle_Set &,
ACE_Event_Handler *eh,
ACE_EH_PTMF callback);
+private:
+
+ ACE_HANDLE get_notify_handle (void);
+
+ int get_socket_event_info (ACE_EH_Dispatch_Info &info);
- /// Notify the appropriate <callback> in the context of the <eh>
- /// associated with <handle> that a particular event has occurred.
- virtual int notify_handle (ACE_EH_Dispatch_Info &dispatch_info);
+ int dispatch_socket_events (ACE_EH_Dispatch_Info &info);
private:
/// Deny access since member-wise won't work...