diff options
Diffstat (limited to 'src/lib/server_finder.h')
| -rw-r--r-- | src/lib/server_finder.h | 20 |
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; }; |
