summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-qtgui/src/lib/qtgui.h17
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_c.cc13
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_c.h4
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_f.cc13
-rw-r--r--gr-qtgui/src/lib/qtgui_sink_f.h4
5 files changed, 23 insertions, 28 deletions
diff --git a/gr-qtgui/src/lib/qtgui.h b/gr-qtgui/src/lib/qtgui.h
index 6edbca12c..9831697ac 100644
--- a/gr-qtgui/src/lib/qtgui.h
+++ b/gr-qtgui/src/lib/qtgui.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,30 +23,31 @@
#ifndef INCLUDED_QTGUI_H
#define INCLUDED_QTGUI_H
+#include <gruel/thread.h>
#include <qapplication.h>
#include "SpectrumGUIClass.h"
class qtgui_event : public QEvent
{
private:
- pthread_mutex_t *pmutex;
+ gruel::mutex &d_mutex;
public:
- qtgui_event(pthread_mutex_t *mut)
- : QEvent((QEvent::Type)(QEvent::User+101))
+ qtgui_event(gruel::mutex &mutex)
+ : QEvent((QEvent::Type)(QEvent::User+101)),
+ d_mutex(mutex)
{
- pmutex = mut;
+ //nop
}
void lock()
{
- pthread_mutex_lock(pmutex);
-
+ d_mutex.lock();
}
void unlock()
{
- pthread_mutex_unlock(pmutex);
+ d_mutex.unlock();
}
};
diff --git a/gr-qtgui/src/lib/qtgui_sink_c.cc b/gr-qtgui/src/lib/qtgui_sink_c.cc
index c12c451b0..05c7b28d5 100644
--- a/gr-qtgui/src/lib/qtgui_sink_c.cc
+++ b/gr-qtgui/src/lib/qtgui_sink_c.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2009,2010 Free Software Foundation, Inc.
+ * Copyright 2008,2009,2010,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -72,7 +72,6 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype,
}
d_main_gui = NULL;
- pthread_mutex_init(&d_pmutex, NULL);
lock();
// Perform fftshift operation;
@@ -107,12 +106,12 @@ qtgui_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required)
void qtgui_sink_c::lock()
{
- pthread_mutex_lock(&d_pmutex);
+ d_mutex.lock();
}
void qtgui_sink_c::unlock()
{
- pthread_mutex_unlock(&d_pmutex);
+ d_mutex.unlock();
}
@@ -151,7 +150,7 @@ qtgui_sink_c::initialize(const bool opengl)
set_update_time(0.1);
d_object = new qtgui_obj(d_qApplication);
- qApp->postEvent(d_object, new qtgui_event(&d_pmutex));
+ qApp->postEvent(d_object, new qtgui_event(d_mutex));
}
@@ -289,7 +288,7 @@ qtgui_sink_c::general_work (int noutput_items,
int j=0;
const gr_complex *in = (const gr_complex*)input_items[0];
- pthread_mutex_lock(&d_pmutex);
+ gruel::scoped_lock lock(d_mutex);
// Update the FFT size from the application
fftresize();
@@ -322,8 +321,6 @@ qtgui_sink_c::general_work (int noutput_items,
}
}
- pthread_mutex_unlock(&d_pmutex);
-
consume_each(j);
return j;
}
diff --git a/gr-qtgui/src/lib/qtgui_sink_c.h b/gr-qtgui/src/lib/qtgui_sink_c.h
index 9aee66503..bbf9983b0 100644
--- a/gr-qtgui/src/lib/qtgui_sink_c.h
+++ b/gr-qtgui/src/lib/qtgui_sink_c.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2009 Free Software Foundation, Inc.
+ * Copyright 2008,2009,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -76,7 +76,7 @@ private:
double d_bandwidth;
std::string d_name;
- pthread_mutex_t d_pmutex;
+ gruel::mutex d_mutex;
bool d_shift;
gri_fft_complex *d_fft;
diff --git a/gr-qtgui/src/lib/qtgui_sink_f.cc b/gr-qtgui/src/lib/qtgui_sink_f.cc
index ab4fd082d..984c2803c 100644
--- a/gr-qtgui/src/lib/qtgui_sink_f.cc
+++ b/gr-qtgui/src/lib/qtgui_sink_f.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2009,2010 Free Software Foundation, Inc.
+ * Copyright 2008,2009,2010,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -72,7 +72,6 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype,
}
d_main_gui = NULL;
- pthread_mutex_init(&d_pmutex, NULL);
lock();
// Perform fftshift operation;
@@ -107,12 +106,12 @@ qtgui_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required)
void qtgui_sink_f::lock()
{
- pthread_mutex_lock(&d_pmutex);
+ d_mutex.lock();
}
void qtgui_sink_f::unlock()
{
- pthread_mutex_unlock(&d_pmutex);
+ d_mutex.unlock();
}
void
@@ -146,7 +145,7 @@ qtgui_sink_f::initialize(const bool opengl)
set_update_time(0.1);
d_object = new qtgui_obj(d_qApplication);
- qApp->postEvent(d_object, new qtgui_event(&d_pmutex));
+ qApp->postEvent(d_object, new qtgui_event(d_mutex));
}
void
@@ -284,7 +283,7 @@ qtgui_sink_f::general_work (int noutput_items,
int j=0;
const float *in = (const float*)input_items[0];
- pthread_mutex_lock(&d_pmutex);
+ gruel::scoped_lock lock(d_mutex);
// Update the FFT size from the application
fftresize();
@@ -317,8 +316,6 @@ qtgui_sink_f::general_work (int noutput_items,
}
}
- pthread_mutex_unlock(&d_pmutex);
-
consume_each(j);
return j;
}
diff --git a/gr-qtgui/src/lib/qtgui_sink_f.h b/gr-qtgui/src/lib/qtgui_sink_f.h
index 0cac35d90..d80a6a198 100644
--- a/gr-qtgui/src/lib/qtgui_sink_f.h
+++ b/gr-qtgui/src/lib/qtgui_sink_f.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2009 Free Software Foundation, Inc.
+ * Copyright 2008,2009,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -74,7 +74,7 @@ private:
double d_bandwidth;
std::string d_name;
- pthread_mutex_t d_pmutex;
+ gruel::mutex d_mutex;
bool d_shift;
gri_fft_complex *d_fft;