Webdar 1.0.0
Web user interface to libdar
server_pool.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef SERVER_POOL_HPP
25#define SERVER_POOL_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <libthreadar/libthreadar.hpp>
36
37 // webdar headers
38#include "reference.hpp"
39#include "central_report.hpp"
40#include "authentication.hpp"
41#include "proto_connexion.hpp"
42#include "server.hpp"
43
45
46class server_pool : public libthreadar::thread_signal, public reference
47{
48public:
49 server_pool(const unsigned int pool_size,
50 const std::shared_ptr<central_report> & log);
51 server_pool(const server_pool & ref) = delete;
52 server_pool(server_pool && ref) noexcept = delete;
53 server_pool & operator = (const server_pool & ref) = delete;
54 server_pool & operator = (server_pool && ref) noexcept = delete;
55 virtual ~server_pool();
56
57 bool run_new_server(const std::shared_ptr<const authentication> & auth,
58 std::unique_ptr<proto_connexion> & source);
59
60 // run() method (inherited from libthreadar::thread_signal to be used
61 // to run the server_pool.
62
63protected:
64
66 virtual void inherited_run() override;
67
69 virtual void signaled_inherited_cancel() override;
70
72
74 virtual void broken_peering_from(reference *obj) override;
75
76
77private:
78 unsigned int max_server;
79 std::shared_ptr<central_report> log;
80 std::deque<server*> dying_ones;
81 libthreadar::condition verrou;
90
91 void cancel_all_servers();
92
93};
94
95#endif
class reference gives a mean to link objects by a peering method
Definition: reference.hpp:47
class managing a pool of server objects
Definition: server_pool.hpp:47
virtual void inherited_run() override
inherited from libthreadar::thread
Definition: server_pool.cpp:160
virtual void broken_peering_from(reference *obj) override
to be informed when a peer has broken the peering with me
Definition: server_pool.cpp:233
virtual void signaled_inherited_cancel() override
inherited from libthreadar::thread_signal
Definition: server_pool.cpp:211