summaryrefslogtreecommitdiff
path: root/src/lib/server_finder.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-06 20:42:12 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-06 20:42:12 +0100
commit43877eccbedc0950ab253e76dd0cea691fd7a4b0 (patch)
tree8b2e1b6d54a07d12b2842bd1c6a362b8e8b22c6d /src/lib/server_finder.h
parent3b970d4c3089bbf7ca2c7f59d8d18142ed49de65 (diff)
parent52fba4ddf170de2e073d1c4736b9407bad525290 (diff)
Merge branch '2.0' of ssh://git.carlh.net/home/carl/git/dcpomatic2 into 2.0
Diffstat (limited to 'src/lib/server_finder.h')
-rw-r--r--src/lib/server_finder.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/server_finder.h b/src/lib/server_finder.h
index ec855938b..3bb0e03f9 100644
--- a/src/lib/server_finder.h
+++ b/src/lib/server_finder.h
@@ -19,13 +19,12 @@
#include "server.h"
#include "signaller.h"
+#include "config.h"
#include <boost/signals2.hpp>
class ServerFinder : public Signaller, public ExceptionStore
{
public:
- boost::signals2::connection connect (boost::function<void (ServerDescription)>);
-
static ServerFinder* instance ();
static void drop ();
@@ -37,23 +36,29 @@ public:
return _disabled;
}
+ std::list<ServerDescription> servers () const;
+
+ /** Emitted whenever the list of servers changes */
+ boost::signals2::signal<void ()> ServersListChanged;
+
private:
ServerFinder ();
~ServerFinder ();
- void broadcast_thread ();
+ void search_thread ();
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;
- /** 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;
@@ -64,5 +69,8 @@ private:
boost::shared_ptr<boost::asio::ip::tcp::acceptor> _listen_acceptor;
bool _stop;
+ boost::condition _search_condition;
+ boost::mutex _search_condition_mutex;
+
static ServerFinder* _instance;
};