diff --git a/lib/base/CFunctionEventJob.cpp b/lib/base/CFunctionEventJob.cpp index 1a55aa00..5afdc988 100644 --- a/lib/base/CFunctionEventJob.cpp +++ b/lib/base/CFunctionEventJob.cpp @@ -15,7 +15,7 @@ #include "CFunctionEventJob.h" // -// CFunctionJob +// CFunctionEventJob // CFunctionEventJob::CFunctionEventJob( diff --git a/lib/base/CJobList.cpp b/lib/base/CJobList.cpp deleted file mode 100644 index 37358890..00000000 --- a/lib/base/CJobList.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2002 Chris Schoeneman - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file COPYING that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "CJobList.h" -#include "IJob.h" -#include "CArch.h" - -// -// CJobList -// - -CJobList::CJobList() -{ - m_mutex = ARCH->newMutex(); -} - -CJobList::~CJobList() -{ - ARCH->closeMutex(m_mutex); -} - -void -CJobList::addJob(IJob* job) -{ - // ignore bogus job - if (job == NULL) { - return; - } - - // make a temporary list with the job. later we'll splice this - // list into our jobs list. since splice() never throws we - // don't have to try/catch to unlock the mutex. - CJobs tmpList; - tmpList.push_front(job); - - // add job to list - ARCH->lockMutex(m_mutex); - m_jobs.splice(m_jobs.begin(), tmpList); - ARCH->unlockMutex(m_mutex); -} - -void -CJobList::removeJob(IJob* job) -{ - if (job != NULL) { - ARCH->lockMutex(m_mutex); - m_jobs.remove(job); - ARCH->unlockMutex(m_mutex); - } -} - -void -CJobList::runJobs() const -{ - // this is a little tricky. to allow any number of threads to - // traverse the list while jobs are added and removed while - // not holding the mutex when running a job (so other threads - // or the running job can add and remove jobs), we insert a - // new element into the list. this element has a NULL job and - // is a "safe place" while we traverse the list. the safe place - // is inserted at the start of the list (with the mutex locked) - // then, for each job, we lock the mutex and move the safe place - // past the next job, unlock the mutex, run the job and repeat - // until there are no more jobs. the safe place will not be - // removed by any other thread and is after every job that has - // been run and before every job that still needs to run. when - // all the jobs have been run we remove the safe place. - - // add the safe place - CJobs tmpList; - tmpList.push_front(NULL); - ARCH->lockMutex(m_mutex); - m_jobs.splice(m_jobs.begin(), tmpList); - CJobs::iterator safePlace = m_jobs.begin(); - - // find the next non-NULL job (NULL jobs are safe places) - CJobs::iterator next = safePlace; - while (next != m_jobs.end() && *next == NULL) - ++next; - while (next != m_jobs.end()) { - // found a job. run it without holding a lock. note the - // race condition here: we release the lock, allowing - // removeJob() to remove this job before we run the job. - // therefore the caller cannot safely destroy the job - // until all runJobs() complete. - IJob* job = *next; - ++next; - m_jobs.splice(next, m_jobs, safePlace); - ARCH->unlockMutex(m_mutex); - job->run(); - - // next real job - ARCH->lockMutex(m_mutex); - next = safePlace; - while (next != m_jobs.end() && *next == NULL) - ++next; - } - - // remove the safe place - m_jobs.erase(safePlace); - ARCH->unlockMutex(m_mutex); -} diff --git a/lib/base/CJobList.h b/lib/base/CJobList.h deleted file mode 100644 index 780d19da..00000000 --- a/lib/base/CJobList.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2002 Chris Schoeneman - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file COPYING that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef CJOBLIST_H -#define CJOBLIST_H - -#include "IArchMultithread.h" -#include "stdlist.h" - -class IJob; - -class CJobList { -public: - CJobList(); - ~CJobList(); - - //! @name manipulators - //@{ - - //! Add a job - /*! - Add a job to the list. The client keeps ownership of the job. - Jobs can be safely added while \c runJobs() is executing. - */ - void addJob(IJob*); - - //! Remove a job - /*! - Remove a job from the list. The client keeps ownership of the job. - Jobs can be safely removed while \c runJobs() is executing. - */ - void removeJob(IJob*); - - //@} - //! @name accessors - //@{ - - //! Run all jobs - /*! - Run all jobs in the list. Any number of threads can call - \c runJobs() at once. Jobs can be added and removed while - \c runJobs() is executing in the same or another thread. - Any job added after \c runJobs() starts will not be run - by that call to runJobs(). Destroying a removed job - while \c runJobs() is executing is not safe unless the - removed completed before \c runJobs() started. - */ - void runJobs() const; - - //@} - -private: - typedef std::list CJobs; - typedef CJobs::iterator iterator; - - CArchMutex m_mutex; - mutable CJobs m_jobs; -}; - -#endif - diff --git a/lib/base/Makefile.am b/lib/base/Makefile.am index 9eb2a526..6ac0f716 100644 --- a/lib/base/Makefile.am +++ b/lib/base/Makefile.am @@ -29,7 +29,6 @@ libbase_a_SOURCES = \ CEventQueue.cpp \ CFunctionEventJob.cpp \ CFunctionJob.cpp \ - CJobList.cpp \ CLog.cpp \ CSimpleEventQueueBuffer.cpp \ CStopwatch.cpp \ @@ -40,8 +39,8 @@ libbase_a_SOURCES = \ XBase.cpp \ CEvent.h \ CEventQueue.h \ + CFunctionEventJob.h \ CFunctionJob.h \ - CJobList.h \ CLog.h \ CPriorityQueue.h \ CSimpleEventQueueBuffer.h \ @@ -49,6 +48,7 @@ libbase_a_SOURCES = \ CString.h \ CStringUtil.h \ CUnicode.h \ + IEventJob.h \ IEventQueue.h \ IEventQueueBuffer.h \ IJob.h \ diff --git a/lib/base/base.dsp b/lib/base/base.dsp index e0c96638..a20e4fb4 100644 --- a/lib/base/base.dsp +++ b/lib/base/base.dsp @@ -87,15 +87,27 @@ LIB32=link.exe -lib # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=.\CEvent.cpp +# End Source File +# Begin Source File + +SOURCE=.\CEventQueue.cpp +# End Source File +# Begin Source File + +SOURCE=.\CFunctionEventJob.cpp +# End Source File +# Begin Source File + SOURCE=.\CFunctionJob.cpp # End Source File # Begin Source File -SOURCE=.\CJobList.cpp +SOURCE=.\CLog.cpp # End Source File # Begin Source File -SOURCE=.\CLog.cpp +SOURCE=.\CSimpleEventQueueBuffer.cpp # End Source File # Begin Source File @@ -111,6 +123,10 @@ SOURCE=.\CUnicode.cpp # End Source File # Begin Source File +SOURCE=.\IEventQueue.cpp +# End Source File +# Begin Source File + SOURCE=.\LogOutputters.cpp # End Source File # Begin Source File @@ -123,15 +139,31 @@ SOURCE=.\XBase.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=.\CEvent.h +# End Source File +# Begin Source File + +SOURCE=.\CEventQueue.h +# End Source File +# Begin Source File + +SOURCE=.\CFunctionEventJob.h +# End Source File +# Begin Source File + SOURCE=.\CFunctionJob.h # End Source File # Begin Source File -SOURCE=.\CJobList.h +SOURCE=.\CLog.h # End Source File # Begin Source File -SOURCE=.\CLog.h +SOURCE=.\CPriorityQueue.h +# End Source File +# Begin Source File + +SOURCE=.\CSimpleEventQueueBuffer.h # End Source File # Begin Source File @@ -151,6 +183,18 @@ SOURCE=.\CUnicode.h # End Source File # Begin Source File +SOURCE=.\IEventJob.h +# End Source File +# Begin Source File + +SOURCE=.\IEventQueue.h +# End Source File +# Begin Source File + +SOURCE=.\IEventQueueBuffer.h +# End Source File +# Begin Source File + SOURCE=.\IJob.h # End Source File # Begin Source File @@ -163,6 +207,10 @@ SOURCE=.\LogOutputters.h # End Source File # Begin Source File +SOURCE=.\TMethodEventJob.h +# End Source File +# Begin Source File + SOURCE=.\TMethodJob.h # End Source File # Begin Source File diff --git a/lib/io/io.dsp b/lib/io/io.dsp index a6afae06..c1346d05 100644 --- a/lib/io/io.dsp +++ b/lib/io/io.dsp @@ -87,26 +87,18 @@ LIB32=link.exe -lib # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=.\CBufferedInputStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\CBufferedOutputStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\CInputStreamFilter.cpp -# End Source File -# Begin Source File - -SOURCE=.\COutputStreamFilter.cpp -# End Source File -# Begin Source File - SOURCE=.\CStreamBuffer.cpp # End Source File # Begin Source File +SOURCE=.\CStreamFilter.cpp +# End Source File +# Begin Source File + +SOURCE=.\IStream.cpp +# End Source File +# Begin Source File + SOURCE=.\XIO.cpp # End Source File # End Group @@ -115,31 +107,15 @@ SOURCE=.\XIO.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=.\CBufferedInputStream.h -# End Source File -# Begin Source File - -SOURCE=.\CBufferedOutputStream.h -# End Source File -# Begin Source File - -SOURCE=.\CInputStreamFilter.h -# End Source File -# Begin Source File - -SOURCE=.\COutputStreamFilter.h -# End Source File -# Begin Source File - SOURCE=.\CStreamBuffer.h # End Source File # Begin Source File -SOURCE=.\IInputStream.h +SOURCE=.\CStreamFilter.h # End Source File # Begin Source File -SOURCE=.\IOutputStream.h +SOURCE=.\IStream.h # End Source File # Begin Source File diff --git a/lib/mt/CTimerThread.cpp b/lib/mt/CTimerThread.cpp deleted file mode 100644 index 2ac63522..00000000 --- a/lib/mt/CTimerThread.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2002 Chris Schoeneman - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file COPYING that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "CTimerThread.h" -#include "CThread.h" -#include "TMethodJob.h" -#include "CLog.h" -#include "CArch.h" - -// -// CTimerThread -// - -CTimerThread::CTimerThread(double timeout, bool* timedOut) : - m_timeout(timeout), - m_timedOut(timedOut) -{ - if (m_timedOut != NULL) { - *m_timedOut = false; - } - if (m_timeout >= 0.0) { - m_callingThread = new CThread(CThread::getCurrentThread()); - m_timingThread = new CThread(new TMethodJob( - this, &CTimerThread::timer)); - } - else { - m_callingThread = NULL; - m_timingThread = NULL; - } -} - -CTimerThread::~CTimerThread() -{ - if (m_timingThread != NULL) { - LOG((CLOG_DEBUG1 "cancelling timeout")); - m_timingThread->cancel(); - m_timingThread->wait(); - LOG((CLOG_DEBUG1 "cancelled timeout")); - delete m_timingThread; - delete m_callingThread; - } -} - -void -CTimerThread::timer(void*) -{ - LOG((CLOG_DEBUG1 "timeout in %f seconds", m_timeout)); - ARCH->sleep(m_timeout); - LOG((CLOG_DEBUG1 "timeout")); - if (m_timedOut != NULL) { - *m_timedOut = true; - } - m_callingThread->cancel(); -} diff --git a/lib/mt/CTimerThread.h b/lib/mt/CTimerThread.h deleted file mode 100644 index 1a0a2b57..00000000 --- a/lib/mt/CTimerThread.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2002 Chris Schoeneman - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file COPYING that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef CTIMERTHREAD_H -#define CTIMERTHREAD_H - -#include "common.h" - -class CThread; - -//! A timer thread -/*! -An object of this class cancels the thread that called the c'tor unless -the object is destroyed before a given timeout. -*/ -class CTimerThread { -public: - //! Cancel calling thread after \c timeout seconds - /*! - Cancels the calling thread after \c timeout seconds unless destroyed - before then. If \c timeout is less than zero then it never times - out and this is a no-op. If \c timedOutFlag is not NULL then it's - set to false in the c'tor and to true if the timeout exipires before - it's cancelled. - */ - CTimerThread(double timeout, bool* timedOutFlag = NULL); - //! Cancel the timer thread - ~CTimerThread(); - -private: - void timer(void*); - - // not implemented - CTimerThread(const CTimerThread&); - CTimerThread& operator=(const CTimerThread&); - -private: - double m_timeout; - bool* m_timedOut; - CThread* m_callingThread; - CThread* m_timingThread; -}; - -#endif - diff --git a/lib/mt/Makefile.am b/lib/mt/Makefile.am index 6eda91d6..1d0dc5ff 100644 --- a/lib/mt/Makefile.am +++ b/lib/mt/Makefile.am @@ -25,17 +25,15 @@ MAINTAINERCLEANFILES = \ noinst_LIBRARIES = libmt.a libmt_a_SOURCES = \ + CCondVar.cpp \ CLock.cpp \ CMutex.cpp \ - CCondVar.cpp \ CThread.cpp \ - CTimerThread.cpp \ XMT.cpp \ CCondVar.h \ CLock.h \ CMutex.h \ CThread.h \ - CTimerThread.h \ XMT.h \ XThread.h \ $(NULL) diff --git a/lib/mt/mt.dsp b/lib/mt/mt.dsp index f926fc1d..fd5b18fd 100644 --- a/lib/mt/mt.dsp +++ b/lib/mt/mt.dsp @@ -103,10 +103,6 @@ SOURCE=.\CThread.cpp # End Source File # Begin Source File -SOURCE=.\CTimerThread.cpp -# End Source File -# Begin Source File - SOURCE=.\XMT.cpp # End Source File # End Group @@ -131,10 +127,6 @@ SOURCE=.\CThread.h # End Source File # Begin Source File -SOURCE=.\CTimerThread.h -# End Source File -# Begin Source File - SOURCE=.\XMT.h # End Source File # Begin Source File diff --git a/lib/net/net.dsp b/lib/net/net.dsp index 2d038c50..42314fc2 100644 --- a/lib/net/net.dsp +++ b/lib/net/net.dsp @@ -91,6 +91,10 @@ SOURCE=.\CNetworkAddress.cpp # End Source File # Begin Source File +SOURCE=.\CSocketMultiplexer.cpp +# End Source File +# Begin Source File + SOURCE=.\CTCPListenSocket.cpp # End Source File # Begin Source File @@ -103,6 +107,18 @@ SOURCE=.\CTCPSocketFactory.cpp # End Source File # Begin Source File +SOURCE=.\IDataSocket.cpp +# End Source File +# Begin Source File + +SOURCE=.\IListenSocket.cpp +# End Source File +# Begin Source File + +SOURCE=.\ISocket.cpp +# End Source File +# Begin Source File + SOURCE=.\XSocket.cpp # End Source File # End Group @@ -115,6 +131,10 @@ SOURCE=.\CNetworkAddress.h # End Source File # Begin Source File +SOURCE=.\CSocketMultiplexer.h +# End Source File +# Begin Source File + SOURCE=.\CTCPListenSocket.h # End Source File # Begin Source File @@ -127,6 +147,10 @@ SOURCE=.\CTCPSocketFactory.h # End Source File # Begin Source File +SOURCE=.\IDataSocket.h +# End Source File +# Begin Source File + SOURCE=.\IListenSocket.h # End Source File # Begin Source File @@ -139,6 +163,14 @@ SOURCE=.\ISocketFactory.h # End Source File # Begin Source File +SOURCE=.\ISocketMultiplexerJob.h +# End Source File +# Begin Source File + +SOURCE=.\TSocketMultiplexerMethodJob.h +# End Source File +# Begin Source File + SOURCE=.\XSocket.h # End Source File # End Group diff --git a/lib/platform/CMSWindowsEventQueueBuffer.cpp b/lib/platform/CMSWindowsEventQueueBuffer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/lib/platform/CMSWindowsEventQueueBuffer.h b/lib/platform/CMSWindowsEventQueueBuffer.h new file mode 100644 index 00000000..e69de29b diff --git a/lib/platform/Makefile.am b/lib/platform/Makefile.am index ec33a35a..1aabff53 100644 --- a/lib/platform/Makefile.am +++ b/lib/platform/Makefile.am @@ -24,6 +24,7 @@ EXTRA_DIST = \ CMSWindowsClipboardTextConverter.cpp \ CMSWindowsClipboardUTF16Converter.cpp \ CMSWindowsDesktop.cpp \ + CMSWindowsEventQueueBuffer.cpp \ CMSWindowsKeyMapper.cpp \ CMSWindowsScreen.cpp \ CMSWindowsScreenSaver.cpp \ @@ -33,6 +34,7 @@ EXTRA_DIST = \ CMSWindowsClipboardTextConverter.h \ CMSWindowsClipboardUTF16Converter.h \ CMSWindowsDesktop.h \ + CMSWindowsEventQueueBuffer.h \ CMSWindowsKeyMapper.h \ CMSWindowsScreen.h \ CMSWindowsScreenSaver.h \ diff --git a/lib/platform/platform.dsp b/lib/platform/platform.dsp index 1fad2189..4dc638dd 100644 --- a/lib/platform/platform.dsp +++ b/lib/platform/platform.dsp @@ -107,6 +107,10 @@ SOURCE=.\CMSWindowsDesktop.cpp # End Source File # Begin Source File +SOURCE=.\CMSWindowsEventQueueBuffer.cpp +# End Source File +# Begin Source File + SOURCE=.\CMSWindowsKeyMapper.cpp # End Source File # Begin Source File @@ -143,6 +147,10 @@ SOURCE=.\CMSWindowsDesktop.h # End Source File # Begin Source File +SOURCE=.\CMSWindowsEventQueueBuffer.h +# End Source File +# Begin Source File + SOURCE=.\CMSWindowsKeyMapper.h # End Source File # Begin Source File diff --git a/lib/server/server.dsp b/lib/server/server.dsp index 536b33d7..1aa729c5 100644 --- a/lib/server/server.dsp +++ b/lib/server/server.dsp @@ -87,6 +87,10 @@ LIB32=link.exe -lib # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=.\CClientListener.cpp +# End Source File +# Begin Source File + SOURCE=.\CClientProxy.cpp # End Source File # Begin Source File @@ -99,11 +103,11 @@ SOURCE=.\CClientProxy1_1.cpp # End Source File # Begin Source File -SOURCE=.\CConfig.cpp +SOURCE=.\CClientProxyUnknown.cpp # End Source File # Begin Source File -SOURCE=.\CHTTPServer.cpp +SOURCE=.\CConfig.cpp # End Source File # Begin Source File @@ -119,6 +123,10 @@ SOURCE=.\CServer.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=.\CClientListener.h +# End Source File +# Begin Source File + SOURCE=.\CClientProxy.h # End Source File # Begin Source File @@ -131,11 +139,11 @@ SOURCE=.\CClientProxy1_1.h # End Source File # Begin Source File -SOURCE=.\CConfig.h +SOURCE=.\CClientProxyUnknown.h # End Source File # Begin Source File -SOURCE=.\CHTTPServer.h +SOURCE=.\CConfig.h # End Source File # Begin Source File diff --git a/lib/synergy/libsynergy.dsp b/lib/synergy/libsynergy.dsp index 928405ea..72deabcd 100644 --- a/lib/synergy/libsynergy.dsp +++ b/lib/synergy/libsynergy.dsp @@ -91,11 +91,7 @@ SOURCE=.\CClipboard.cpp # End Source File # Begin Source File -SOURCE=.\CInputPacketStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\COutputPacketStream.cpp +SOURCE=.\CPacketStreamFilter.cpp # End Source File # Begin Source File @@ -107,6 +103,18 @@ SOURCE=.\CScreen.cpp # End Source File # Begin Source File +SOURCE=.\IClipboard.cpp +# End Source File +# Begin Source File + +SOURCE=.\IPlatformScreen.cpp +# End Source File +# Begin Source File + +SOURCE=.\IScreen.cpp +# End Source File +# Begin Source File + SOURCE=.\XScreen.cpp # End Source File # Begin Source File @@ -123,15 +131,11 @@ SOURCE=.\CClipboard.h # End Source File # Begin Source File -SOURCE=.\CInputPacketStream.h -# End Source File -# Begin Source File - SOURCE=.\ClipboardTypes.h # End Source File # Begin Source File -SOURCE=.\COutputPacketStream.h +SOURCE=.\CPacketStreamFilter.h # End Source File # Begin Source File @@ -163,15 +167,7 @@ SOURCE=.\IPrimaryScreen.h # End Source File # Begin Source File -SOURCE=.\IPrimaryScreenReceiver.h -# End Source File -# Begin Source File - -SOURCE=.\IScreenFactory.h -# End Source File -# Begin Source File - -SOURCE=.\IScreenReceiver.h +SOURCE=.\IScreen.h # End Source File # Begin Source File @@ -183,10 +179,6 @@ SOURCE=.\ISecondaryScreen.h # End Source File # Begin Source File -SOURCE=.\IServer.h -# End Source File -# Begin Source File - SOURCE=.\KeyTypes.h # End Source File # Begin Source File