Make a mutex locker.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 6 Apr 2013 12:35:18 +0000 (14:35 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 6 Apr 2013 12:35:18 +0000 (14:35 +0200)
cubemap.cpp

index b02121d78b8b6013fbafd2942cadee6f35192fa2..6095ce547b99d2a0c448b1d940e0cb4fc6c09aa8 100644 (file)
 #define STREAM_ID "stream"
 #define STREAM_URL "http://gruessi.zrh.sesse.net:4013/"
 #define BACKLOG_SIZE 1048576
+#define PORT 9094
 
 using namespace std;
 
+// Locks a pthread mutex, RAII-style.
+class MutexLock {
+public:
+       MutexLock(pthread_mutex_t *mutex);
+       ~MutexLock();
+
+private:
+       pthread_mutex_t *mutex;
+};
+       
+MutexLock::MutexLock(pthread_mutex_t *mutex)
+       : mutex(mutex)
+{
+       pthread_mutex_lock(mutex);
+}
+
+MutexLock::~MutexLock()
+{
+       pthread_mutex_unlock(mutex);
+}
+
 struct Client {
        enum State { READING_REQUEST, SENDING_HEADER, SENDING_DATA };
        State state;