summaryrefslogtreecommitdiff
path: root/src/lib/encode_server.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-12-06 20:17:47 +0000
committerCarl Hetherington <cth@carlh.net>2015-12-11 11:56:23 +0000
commit6fa353595ce8f784b7d5004a6c38c78bddae94c7 (patch)
treed50c1273d519d97f3c4ad5e6ca4532f3ecbaa6d9 /src/lib/encode_server.h
parent17df947ac256397311a11894062070f8069c7e75 (diff)
Split EncodeServer into that and Server.
Diffstat (limited to 'src/lib/encode_server.h')
-rw-r--r--src/lib/encode_server.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/lib/encode_server.h b/src/lib/encode_server.h
index f6f1fc9b9..d0c061eb3 100644
--- a/src/lib/encode_server.h
+++ b/src/lib/encode_server.h
@@ -21,9 +21,10 @@
#define DCPOMATIC_ENCODE_SERVER_H
/** @file src/encode_server.h
- * @brief Server class.
+ * @brief EncodeServer class.
*/
+#include "server.h"
#include "exception_store.h"
#include <boost/thread.hpp>
#include <boost/asio.hpp>
@@ -37,34 +38,28 @@ class Log;
* @brief A class to run a server which can accept requests to perform JPEG2000
* encoding work.
*/
-class EncodeServer : public ExceptionStore, public boost::noncopyable
+class EncodeServer : public Server, public ExceptionStore
{
public:
- EncodeServer (boost::shared_ptr<Log> log, bool verbose);
+ EncodeServer (boost::shared_ptr<Log> log, bool verbose, int num_threads);
~EncodeServer ();
- void run (int num_threads);
+ void run ();
private:
+ void handle (boost::shared_ptr<Socket>);
void worker_thread ();
int process (boost::shared_ptr<Socket> socket, struct timeval &, struct timeval &);
void broadcast_thread ();
void broadcast_received ();
- void start_accept ();
- void handle_accept (boost::shared_ptr<Socket>, boost::system::error_code const &);
-
- bool _terminate;
std::vector<boost::thread *> _worker_threads;
std::list<boost::shared_ptr<Socket> > _queue;
- boost::mutex _worker_mutex;
boost::condition _full_condition;
boost::condition _empty_condition;
boost::shared_ptr<Log> _log;
bool _verbose;
-
- boost::asio::io_service _io_service;
- boost::asio::ip::tcp::acceptor _acceptor;
+ int _num_threads;
struct Broadcast {