summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/queue.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/queue.h b/src/queue.h
index e93d7a4..6b143fd 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -57,7 +57,7 @@ public:
void plength();
private:
- bool locked;
+ volatile bool locked;
int limit;
buf_t *head;
buf_t *tail;
@@ -102,14 +102,13 @@ Queue<T>::~Queue()
template<typename T>
void Queue<T>::push(T *t)
{
- pthread_mutex_lock(&mutex);
-
if(locked) {
delete t;
- pthread_mutex_unlock(&mutex);
return;
}
+ pthread_mutex_lock(&mutex);
+
buf_t *b = (buf_t*)xmalloc(sizeof(*b));
b->data = (void*)t;
@@ -220,9 +219,9 @@ void Queue<T>::plength()
template<typename T>
void Queue<T>::lock()
{
- pthread_mutex_lock(&mutex);
+ fprintf(stderr, "Lock this motherfucker..."); fflush(stderr);
locked = true;
- pthread_mutex_unlock(&mutex);
+ fprintf(stderr, "done\n"); fflush(stderr);
}
/**
@@ -231,9 +230,9 @@ void Queue<T>::lock()
template<typename T>
void Queue<T>::unlock()
{
- pthread_mutex_lock(&mutex);
+ fprintf(stderr, "Unlock this motherfucker..."); fflush(stderr);
locked = false;
- pthread_mutex_unlock(&mutex);
+ fprintf(stderr, "done\n"); fflush(stderr);
}
#endif