Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / ace / XtReactor / XtReactor.h
blob8e5d4bc3e3697153ed5c8892f54a04528d7996d3
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file XtReactor.h
7 * @author Eric C. Newton <ecn@clark.net>
8 * @author Kirill Rybaltchenko <Kirill.Rybaltchenko@cern.ch>
9 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
11 //=============================================================================
14 #ifndef ACE_XTREACTOR_H
15 #define ACE_XTREACTOR_H
16 #include /**/ "ace/pre.h"
18 #include /**/ "ace/config-all.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/XtReactor/ACE_XtReactor_export.h"
24 #include "ace/Select_Reactor.h"
26 #include /**/ <X11/Intrinsic.h>
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 /**
31 * @class ACE_XtReactorID
33 * @brief This little class is necessary due to the way that Microsoft
34 * implements sockets to be pointers rather than indices.
36 class ACE_XtReactor_Export ACE_XtReactorID
38 public:
39 /// Magic cookie.
40 XtInputId id_;
42 /// Underlying handle.
43 ACE_HANDLE handle_;
45 /// Pointer to next node in the linked list.
46 ACE_XtReactorID *next_;
49 /**
50 * @class ACE_XtReactor
52 * @brief An object-oriented event demultiplexor and event handler
53 * dispatcher that uses the X Toolkit functions.
55 class ACE_XtReactor_Export ACE_XtReactor : public ACE_Select_Reactor
57 public:
58 ACE_XtReactor (XtAppContext context = 0,
59 size_t size = DEFAULT_SIZE,
60 bool restart = false,
61 ACE_Sig_Handler * = 0);
62 virtual ~ACE_XtReactor ();
64 XtAppContext context () const;
65 void context (XtAppContext);
67 // = Timer operations.
68 virtual long schedule_timer (ACE_Event_Handler *event_handler,
69 const void *arg,
70 const ACE_Time_Value &delay,
71 const ACE_Time_Value &interval);
72 virtual int reset_timer_interval (long timer_id,
73 const ACE_Time_Value &interval);
74 virtual int cancel_timer (ACE_Event_Handler *handler,
75 int dont_call_handle_close = 1);
77 virtual int cancel_timer (long timer_id,
78 const void **arg = 0,
79 int dont_call_handle_close = 1);
81 protected:
82 // = Register timers/handles with Xt.
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,
99 ACE_Reactor_Mask);
101 /// Suspend the <Event_Handler> associated with @a handle
102 virtual int suspend_i (ACE_HANDLE handle);
104 /// Resume the <Event_Handler> associated with @a handle
105 virtual int resume_i (ACE_HANDLE handle);
107 /// Synchronize XtInputHandler for @a handle
108 virtual void synchronize_XtInput(ACE_HANDLE handle);
110 /// Compute needed Xt condition by looking at base class wait set.
111 virtual int compute_Xt_condition(ACE_HANDLE handle);
113 /// Wait for events to occur.
114 virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &,
115 ACE_Time_Value *);
117 ///Wait for Xt events to occur.
118 virtual int XtWaitForMultipleEvents (int,
119 ACE_Select_Reactor_Handle_Set &,
120 ACE_Time_Value *);
122 XtAppContext context_;
123 ACE_XtReactorID *ids_;
124 XtIntervalId timeout_;
126 private:
127 /// This method ensures there's an Xt timeout for the first timeout
128 /// in the Reactor's Timer_Queue.
129 void reset_timeout ();
131 // = Integrate with the X callback function mechanism.
132 static void TimerCallbackProc (XtPointer closure, XtIntervalId *id);
133 static void InputCallbackProc (XtPointer closure, int* source, XtInputId *id);
135 /// Deny access since member-wise won't work...
136 ACE_XtReactor (const ACE_XtReactor &);
137 ACE_XtReactor &operator = (const ACE_XtReactor &);
140 ACE_END_VERSIONED_NAMESPACE_DECL
142 #include /**/ "ace/post.h"
144 #endif /* ACE_XTREACTOR_H */