]> git.sesse.net Git - cubemap/blobdiff - server.h
Fix the broken SO_REUSEADDR.
[cubemap] / server.h
index dea24d894e4cf9e5c9ea5ab7d3e96fa77f861a08..0f93b7f0b034caa1eb88a276f3b2aa40fa78fc83 100644 (file)
--- a/server.h
+++ b/server.h
@@ -57,14 +57,24 @@ public:
 
        // Start a new thread that handles clients.
        void run();
 
        // Start a new thread that handles clients.
        void run();
+
+       // Stop the thread.
+       void stop();
+
        void add_client(int sock);
        void add_stream(const std::string &stream_id);
        void set_header(const std::string &stream_id, const std::string &header);
        void add_data(const std::string &stream_id, const char *data, size_t bytes);
 
 private:
        void add_client(int sock);
        void add_stream(const std::string &stream_id);
        void set_header(const std::string &stream_id, const std::string &header);
        void add_data(const std::string &stream_id, const char *data, size_t bytes);
 
 private:
+       pthread_t worker_thread;
+
+       // All variables below this line are protected by the mutex.
        pthread_mutex_t mutex;
 
        pthread_mutex_t mutex;
 
+       // If the thread should stop or not.
+       bool should_stop;       
+
        // Map from stream ID to stream.
        std::map<std::string, Stream> streams;
 
        // Map from stream ID to stream.
        std::map<std::string, Stream> streams;