KD SOAP  1.10.0
KDSoapServerThread_p.h
1 /****************************************************************************
2 **
3 ** This file is part of the KD Soap library.
4 **
5 ** SPDX-FileCopyrightText: 2010-2020 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 private:
46  QMutex m_socketListMutex;
47  KDSoapSocketList *socketListForServer(KDSoapServer *server);
48  typedef QHash<KDSoapServer *, KDSoapSocketList *> SocketLists;
49  SocketLists m_socketLists;
50 
51  QAtomicInt m_incomingConnectionCount;
52 };
53 
54 class KDSoapServerThread : public QThread
55 {
56  Q_OBJECT
57 public:
58  explicit KDSoapServerThread(QObject *parent = 0);
59  ~KDSoapServerThread();
60 
61  void startThread();
62  void quitThread();
63 
64  int socketCount() const;
65  int socketCountForServer(const KDSoapServer *server) const;
66  int totalConnectionCountForServer(const KDSoapServer *server) const;
67  void resetTotalConnectionCountForServer(const KDSoapServer *server);
68 
69  void disconnectSocketsForServer(KDSoapServer *server, QSemaphore &semaphore);
70  void handleIncomingConnection(int socketDescriptor, KDSoapServer *server);
71 
72 protected:
73  virtual void run() override;
74 
75 private:
76  void start(); // use startThread instead
77  void quit(); // use quitThread instead
78  KDSoapServerThreadImpl *d;
79  QSemaphore m_semaphore;
80 };
81 
82 #endif // KDSOAPSERVERTHREAD_P_H
Definition: KDSoapServer.h:35

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/