projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Separate ExceptionStore.
[dcpomatic.git]
/
src
/
lib
/
server_finder.h
diff --git
a/src/lib/server_finder.h
b/src/lib/server_finder.h
index 01e26f7dfee1aa3a7c432d8ba9c68c9d4e777057..bd6d793044ffdf468d41e9b7cecc6950556fb38b 100644
(file)
--- a/
src/lib/server_finder.h
+++ b/
src/lib/server_finder.h
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013
-2015
Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-17,39
+17,64
@@
*/
*/
+#include "signaller.h"
+#include "server_description.h"
+#include "config.h"
+#include "exception_store.h"
#include <boost/signals2.hpp>
#include <boost/signals2.hpp>
-#include
"server.h"
+#include
<boost/thread/condition.hpp>
-class ServerFinder
+class Socket;
+
+class ServerFinder : public Signaller, public ExceptionStore
{
public:
{
public:
- void connect (boost::function<void (ServerDescription)>);
-
static ServerFinder* instance ();
static ServerFinder* instance ();
+ static void drop ();
void disable () {
_disabled = true;
}
void disable () {
_disabled = true;
}
+ bool disabled () const {
+ return _disabled;
+ }
+
+ std::list<ServerDescription> servers () const;
+
+ /** Emitted whenever the list of servers changes */
+ boost::signals2::signal<void ()> ServersListChanged;
+
private:
ServerFinder ();
private:
ServerFinder ();
+ ~ServerFinder ();
- void
broadcast
_thread ();
+ void
search
_thread ();
void listen_thread ();
bool server_found (std::string) const;
void listen_thread ();
bool server_found (std::string) const;
+ void start_accept ();
+ void handle_accept (boost::system::error_code ec, boost::shared_ptr<Socket> socket);
- boost::signals2::signal<void (ServerDescription)> ServerFound;
+ void config_changed (Config::Property what);
+ void search_now ();
bool _disabled;
bool _disabled;
-
- /** Thread to periodically issue broadcasts to find encoding servers */
- boost::thread* _
broadcast
_thread;
+
+ /** Thread to periodically issue broadcasts
and requests
to find encoding servers */
+ boost::thread* _
search
_thread;
/** Thread to listen to the responses from servers */
boost::thread* _listen_thread;
std::list<ServerDescription> _servers;
mutable boost::mutex _mutex;
/** Thread to listen to the responses from servers */
boost::thread* _listen_thread;
std::list<ServerDescription> _servers;
mutable boost::mutex _mutex;
+ boost::asio::io_service _listen_io_service;
+ boost::shared_ptr<boost::asio::ip::tcp::acceptor> _listen_acceptor;
+ bool _stop;
+
+ boost::condition _search_condition;
+ boost::mutex _search_condition_mutex;
+
static ServerFinder* _instance;
};
static ServerFinder* _instance;
};