KDSOAP
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2010-2011 Klaralvdalens Datakonsult AB. All rights reserved. 00003 ** 00004 ** This file is part of the KD Soap library. 00005 ** 00006 ** Licensees holding valid commercial KD Soap licenses may use this file in 00007 ** accordance with the KD Soap Commercial License Agreement provided with 00008 ** the Software. 00009 ** 00010 ** 00011 ** This file may be distributed and/or modified under the terms of the 00012 ** GNU General Public License version 2 and version 3 as published by the 00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** Contact info@kdab.com if any conditions of this licensing are not 00019 ** clear to you. 00020 ** 00021 **********************************************************************/ 00022 #ifndef KDSOAPSERVERTHREAD_P_H 00023 #define KDSOAPSERVERTHREAD_P_H 00024 00025 #include <QThread> 00026 #include <QSemaphore> 00027 #include <QMutex> 00028 #include <QHash> 00029 class KDSoapServer; 00030 class KDSoapSocketList; 00031 00032 class KDSoapServerThreadImpl : public QObject 00033 { 00034 Q_OBJECT 00035 public: 00036 KDSoapServerThreadImpl(); 00037 ~KDSoapServerThreadImpl(); 00038 00039 public Q_SLOTS: 00040 void handleIncomingConnection(int socketDescriptor, KDSoapServer* server); 00041 void disconnectSocketsForServer(KDSoapServer* server, QSemaphore* semaphore); 00042 void quit(); 00043 00044 public: 00045 int socketCount(); 00046 int socketCountForServer(const KDSoapServer* server); 00047 00048 void addIncomingConnection(); 00049 private: 00050 QMutex m_socketListMutex; 00051 KDSoapSocketList* socketListForServer(KDSoapServer* server); 00052 typedef QHash<KDSoapServer*, KDSoapSocketList*> SocketLists; 00053 SocketLists m_socketLists; 00054 00055 QAtomicInt m_incomingConnectionCount; 00056 }; 00057 00058 class KDSoapServerThread : public QThread 00059 { 00060 Q_OBJECT 00061 public: 00062 explicit KDSoapServerThread(QObject *parent = 0); 00063 ~KDSoapServerThread(); 00064 00065 void startThread(); 00066 void quitThread(); 00067 00068 int socketCount() const; 00069 int socketCountForServer(const KDSoapServer* server) const; 00070 void disconnectSocketsForServer(KDSoapServer* server, QSemaphore& semaphore); 00071 void handleIncomingConnection(int socketDescriptor, KDSoapServer* server); 00072 00073 protected: 00074 virtual void run(); 00075 00076 private: 00077 void start(); // use startThread instead 00078 void quit(); // use quitThread instead 00079 KDSoapServerThreadImpl* d; 00080 QSemaphore m_semaphore; 00081 }; 00082 00083 #endif // KDSOAPSERVERTHREAD_P_H