24 #include <fvutils/net/fuse_server.h> 25 #include <fvutils/net/fuse_server_client_thread.h> 27 #include <core/threading/thread_collector.h> 28 #include <netcomm/utils/acceptor_thread.h> 60 FuseServer::FuseServer(
bool enable_ipv4,
bool enable_ipv6,
61 const std::string &listen_ipv4,
const std::string &listen_ipv6,
65 __thread_collector = collector;
69 "FuseNetworkAcceptorThread"));
73 "FuseNetworkAcceptorThread"));
75 if (__thread_collector) {
76 for (
size_t i = 0; i < __acceptor_threads.size(); ++i) {
77 __thread_collector->
add(__acceptor_threads[i]);
80 for (
size_t i = 0; i < __acceptor_threads.size(); ++i) {
81 __acceptor_threads[i]->start();
90 for (
size_t i = 0; i < __acceptor_threads.size(); ++i) {
91 if ( __thread_collector ) {
92 __thread_collector->
remove(__acceptor_threads[i]);
94 __acceptor_threads[i]->cancel();
95 __acceptor_threads[i]->join();
97 delete __acceptor_threads[i];
99 __acceptor_threads.clear();
101 for (__cit = __clients.begin(); __cit != __clients.end(); ++__cit) {
102 if ( __thread_collector ) {
104 __thread_collector->
remove(*__cit);
119 if ( __thread_collector) {
120 __thread_collector->
add(client);
124 __clients.push_back_locked(client);
134 __dead_clients.push_back_locked(client);
143 __dead_clients.lock();
148 while ( ! __dead_clients.empty() ) {
149 dcit = __dead_clients.begin();
151 if ( __thread_collector ) {
153 __thread_collector->
remove(*dcit);
158 if ( (__cit = find(__clients.begin(), __clients.end(), *dcit)) != __clients.end() ) {
159 __clients.erase(__cit);
163 __dead_clients.erase(dcit);
168 __dead_clients.unlock();
virtual void loop()
Code to execute in the thread.
void connection_died(FuseServerClientThread *client)
Connection died.
virtual void remove(ThreadList &tl)=0
Remove multiple threads.
Fawkes library namespace.
Thread class encapsulation of pthreads.
TCP stream socket over IP.
void wakeup()
Wake up thread.
FUSE Server Client Thread.
virtual void add(ThreadList &tl)=0
Add multiple threads.
virtual void add_connection(fawkes::StreamSocket *s)
Add an incoming connection.
virtual ~FuseServer()
Destructor.
void start(bool wait=true)
Call this method to start the thread.