KD SOAP  2.0.0
KDSoapServerThread_p.h
1 /****************************************************************************
2 **
3 ** This file is part of the KD Soap library.
4 **
5 ** SPDX-FileCopyrightText: 2010-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: LicenseRef-KDAB-KDSoap-AGPL3-Modified OR LicenseRef-KDAB-KDSoap OR LicenseRef-KDAB-KDSoap-US
8 **
9 ** Licensees holding valid commercial KD Soap licenses may use this file in
10 ** accordance with the KD Soap Commercial License Agreement provided with
11 ** the Software.
12 **
13 ** Contact info@kdab.com if any conditions of this licensing are not clear to you.
14 **
15 ****************************************************************************/
16 #ifndef KDSOAPSERVERTHREAD_P_H
17 #define KDSOAPSERVERTHREAD_P_H
18 
19 #include <QThread>
20 #include <QSemaphore>
21 #include <QMutex>
22 #include <QHash>
23 class KDSoapServer;
24 class KDSoapSocketList;
25 
26 class KDSoapServerThreadImpl : public QObject
27 {
28  Q_OBJECT
29 public:
30  KDSoapServerThreadImpl();
31  ~KDSoapServerThreadImpl();
32 
33 public Q_SLOTS:
34  void handleIncomingConnection(int socketDescriptor, KDSoapServer *server);
35  void disconnectSocketsForServer(KDSoapServer *server, QSemaphore *semaphore);
36  void quit();
37 
38 public:
39  int socketCount();
40  int socketCountForServer(const KDSoapServer *server);
41  int totalConnectionCountForServer(const KDSoapServer *server);
42  void resetTotalConnectionCountForServer(const KDSoapServer *server);
43 
44  void addIncomingConnection();
45 
46 private:
47  QMutex m_socketListMutex;
48  KDSoapSocketList *socketListForServer(KDSoapServer *server);
50  SocketLists m_socketLists;
51 
52  QAtomicInt m_incomingConnectionCount;
53 };
54 
55 class KDSoapServerThread : public QThread
56 {
57  Q_OBJECT
58 public:
59  explicit KDSoapServerThread(QObject *parent = 0);
60  ~KDSoapServerThread();
61 
62  void startThread();
63  void quitThread();
64 
65  int socketCount() const;
66  int socketCountForServer(const KDSoapServer *server) const;
67  int totalConnectionCountForServer(const KDSoapServer *server) const;
68  void resetTotalConnectionCountForServer(const KDSoapServer *server);
69 
70  void disconnectSocketsForServer(KDSoapServer *server, QSemaphore &semaphore);
71  void handleIncomingConnection(int socketDescriptor, KDSoapServer *server);
72 
73 protected:
74  virtual void run() override;
75 
76 private:
77  void start(); // use startThread instead
78  void quit(); // use quitThread instead
79  KDSoapServerThreadImpl *d;
80  QSemaphore m_semaphore;
81 };
82 
83 #endif // KDSOAPSERVERTHREAD_P_H
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QMutex
QObject::Q_SLOTS
Q_SLOTSQ_SLOTS
QThread
KDSoapServer
Definition: KDSoapServer.h:36
QThread::quit
void quit()
QObject
QThread::run
virtual void run()
QThread::start
void start(QThread::Priority priority)
QAtomicInt
QSemaphore
QHash< KDSoapServer *, KDSoapSocketList * >

© 2010-2022 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-soap/
Generated on Fri Jul 22 2022 15:57:43 for KD SOAP by doxygen 1.8.20