• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Synchronizer.h

Go to the documentation of this file.
00001 /* AbiCollab - Code to enable the modification of remote documents.
00002  * Copyright (C) 2007-2008 by Marc Maurer <uwog@uwog.net>
00003  * Copyright (C) 2007 by Ryan Pavlik <abiryan@ryand.net>
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA.
00019  */
00020 
00021 #ifndef __SYNCHRONIZER__
00022 #define __SYNCHRONIZER__
00023 
00024 #include <boost/function.hpp>
00025 #include <ut_assert.h>
00026 
00027 class Synchronizer;
00028 
00029 #ifdef _WIN32
00030 // Windows implementation requirements
00031 #define WM_ABI_SYNCHRONIZER WM_USER+15
00032 #include <windows.h>
00033 #include <session/xp/AbiCollabSessionManager.h>
00034 #else
00035 // Unix implementation requirements
00036 #include <unistd.h>
00037 #include <glib.h>
00038 #endif
00039 
00040 class Synchronizer
00041 {
00042 public:
00043 #ifdef _WIN32
00044     // Windows-only static stuff
00045     static bool sm_bClassRegistered;
00046     static int sm_iMessageWindows;
00047 
00048     static LRESULT CALLBACK s_wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00049     static void _registerWndClass();
00050     static void _unregisterWndClass();
00051 #endif
00052 
00053     // XP prototypes
00054     Synchronizer(boost::function<void ()> signalhandler);
00055     virtual ~Synchronizer();
00056 
00057     void signal();
00058 
00059     void callMainloop()
00060     {
00061         _consume();
00062         m_signalhandler();
00063     }
00064 
00065 private:
00066     void _consume();
00067 
00069 // PRIVATE DATA
00071 // XP members
00072     boost::function<void ()> m_signalhandler;
00073 
00074 #ifdef _WIN32
00075     HWND m_hWnd;
00076     bool m_bIsProcessing;
00077     int m_iDeferredMessages;
00078 
00079     // This hack should not be needed if the Synchronizer was always uses
00080     // as a shared pointer. Without that, when this object is destroyed as the
00081     // result of a mainloop callback, we can't determine the number of deferred
00082     // signals anymore.
00083     // If this hack is removed (because all uses of the Synchronizer are
00084     // shared pointer uses, and the wndProc has been updated accordingly),
00085     // then make sure the testcase from http://bugzilla.abisource.com/show_bug.cgi?id=12264
00086     // still works...
00087     bool* m_bIsDestroyed;
00088 #else
00089     int fdr;
00090     int fdw;
00091     GIOChannel* io_channel;
00092     guint io_channel_watch_id;
00093 #endif
00094 };
00095 
00096 #endif /* __SYNCHRONIZER__ */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1