Msg_WFMO_Reactor.cpp

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

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7