Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Msg_WFMO_Reactor.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: Msg_WFMO_Reactor.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:21 chad Exp $
00003 
00004 #include "ace/Msg_WFMO_Reactor.h"
00005 
00006 ACE_RCSID(ace, Msg_WFMO_Reactor, "$Id: Msg_WFMO_Reactor.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:21 chad Exp $")
00007 
00008 #if defined (ACE_WIN32) && !defined (ACE_LACKS_MSG_WFMO)
00009 
00010 #if !defined (__ACE_INLINE__)
00011 #include "ace/Msg_WFMO_Reactor.i"
00012 #endif /* __ACE_INLINE__ */
00013 
00014 ACE_Msg_WFMO_Reactor::ACE_Msg_WFMO_Reactor (ACE_Sig_Handler *sh, 
00015                                             ACE_Timer_Queue *tq)
00016   : ACE_WFMO_Reactor (sh, tq)
00017 {
00018 }
00019 
00020 ACE_Msg_WFMO_Reactor::ACE_Msg_WFMO_Reactor (size_t size,
00021                                             int unused,
00022                                             ACE_Sig_Handler *sh,
00023                                             ACE_Timer_Queue *tq)
00024   : ACE_WFMO_Reactor (size, unused, sh, tq)
00025 {
00026 }
00027 
00028 ACE_Msg_WFMO_Reactor::~ACE_Msg_WFMO_Reactor (void)
00029 {
00030 }
00031 
00032 DWORD
00033 ACE_Msg_WFMO_Reactor::wait_for_multiple_events (int timeout,
00034                                                 int alertable)
00035 {
00036   // Wait for any of handles_ to be active, or until timeout expires.
00037   // If <alertable> is enabled allow asynchronous completion of
00038   // ReadFile and WriteFile operations. QS_ALLINPUT allows
00039   // <MsgWaitForMultipleObjectsEx> to wait for any message is in the
00040   // queue.
00041 #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0))
00042   return ::MsgWaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (),
00043                                         this->handler_rep_.handles (),
00044                                         timeout,
00045                                         QS_ALLINPUT,
00046                                         alertable);
00047 #else
00048   ACE_UNUSED_ARG (alertable);
00049   return ::MsgWaitForMultipleObjects (this->handler_rep_.max_handlep1 (),
00050                                       this->handler_rep_.handles (),
00051                                       FALSE,
00052                                       timeout,
00053                                       QS_ALLINPUT);
00054 #endif /* (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) */
00055 }
00056 
00057 int
00058 ACE_Msg_WFMO_Reactor::dispatch_window_messages (void)
00059 {
00060   int number_of_messages = 0;
00061   MSG msg;
00062       
00063   // Process all pending message from this thread's message queue
00064   while (::PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
00065     {
00066       ::TranslateMessage (&msg);
00067       if (msg.message == WM_QUIT)
00068         {
00069           // Should inform the main thread
00070           ::PostQuitMessage (msg.wParam); 
00071           return -1;
00072         }
00073       
00074       ::DispatchMessage (&msg);
00075       number_of_messages++;
00076     }
00077   
00078   return number_of_messages;
00079 }
00080 
00081 DWORD
00082 ACE_Msg_WFMO_Reactor::poll_remaining_handles (DWORD slot)
00083 {
00084   return ::MsgWaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot,
00085                                       this->handler_rep_.handles () + slot,
00086                                       FALSE,
00087                                       0,
00088                                       QS_ALLINPUT);
00089 }
00090 
00091 #endif /* ACE_WIN32 && !ACE_LACKS_MSG_WFMO */

Generated on Mon Jun 16 11:20:27 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002