3 //=============================================================================
7 * @author Nagarajan Surendran <naga@cs.wustl.edu>
9 //=============================================================================
12 #ifndef ACE_TKREACTOR_H
13 #define ACE_TKREACTOR_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/config-all.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/TkReactor/ACE_TkReactor_export.h"
23 #include "ace/Select_Reactor.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 * @class ACE_TkReactorID
31 * @brief This little class is necessary due to the way that Microsoft
32 * implements sockets to be pointers rather than indices.
34 class ACE_TkReactor_Export ACE_TkReactorID
37 /// Underlying handle.
40 /// Pointer to next node in the linked list.
41 ACE_TkReactorID
*next_
;
46 class ACE_TkReactor_Export ACE_TkReactor_Input_Callback
49 ACE_TkReactor
*reactor_
;
54 * @class ACE_TkReactor
56 * @brief An object-oriented event demultiplexor and event handler
57 * dispatcher that uses the Tk functions.
59 class ACE_TkReactor_Export ACE_TkReactor
: public ACE_Select_Reactor
62 ACE_TkReactor (size_t size
= DEFAULT_SIZE
,
64 ACE_Sig_Handler
* = 0);
66 virtual ~ACE_TkReactor ();
68 // = Timer operations.
69 virtual long schedule_timer (ACE_Event_Handler
*event_handler
,
71 const ACE_Time_Value
&delay
,
72 const ACE_Time_Value
&interval
);
73 virtual int reset_timer_interval (long timer_id
,
74 const ACE_Time_Value
&interval
);
75 virtual int cancel_timer (ACE_Event_Handler
*handler
,
76 int dont_call_handle_close
= 1);
77 virtual int cancel_timer (long timer_id
,
79 int dont_call_handle_close
= 1);
82 // = Register timers/handles with Tk.
83 /// Register a single @a handler.
84 virtual int register_handler_i (ACE_HANDLE handle
,
85 ACE_Event_Handler
*handler
,
86 ACE_Reactor_Mask mask
);
88 /// Register a set of <handlers>.
89 virtual int register_handler_i (const ACE_Handle_Set
&handles
,
90 ACE_Event_Handler
*handler
,
91 ACE_Reactor_Mask mask
);
93 /// Remove the @a handler associated with this @a handle.
94 virtual int remove_handler_i (ACE_HANDLE handle
,
95 ACE_Reactor_Mask mask
);
97 /// Remove a set of <handles>.
98 virtual int remove_handler_i (const ACE_Handle_Set
&handles
,
101 /// Removes an Tk FileHandler.
102 virtual void remove_TkFileHandler (ACE_HANDLE handle
);
104 /// Wait for events to occur.
105 virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set
&,
108 ///Wait for Tk events to occur.
109 virtual int TkWaitForMultipleEvents (int,
110 ACE_Select_Reactor_Handle_Set
&,
113 ACE_TkReactorID
*ids_
;
114 Tk_TimerToken timeout_
;
117 /// This method ensures there's a Tk timeout for the first timeout in
118 /// the Reactor's Timer_Queue.
119 void reset_timeout ();
121 // = Integrate with the X callback function mechanism.
122 static void TimerCallbackProc (ClientData cd
);
123 static void InputCallbackProc (ClientData cd
,int mask
);
125 /// Deny access since member-wise won't work...
126 ACE_TkReactor (const ACE_TkReactor
&);
127 ACE_TkReactor
&operator = (const ACE_TkReactor
&);
130 ACE_END_VERSIONED_NAMESPACE_DECL
132 #include /**/ "ace/post.h"
133 #endif /* ACE_TK_REACTOR_H */