Replace QMutex with POSIX threads.

merge-requests/1/head
Teuniz 2017-07-09 14:32:25 +02:00
rodzic 33888cfc49
commit 8603a339e7
5 zmienionych plików z 19 dodań i 17 usunięć

Wyświetl plik

@ -29,13 +29,13 @@
#ifndef DSR_GLOBAL_H
#define DSR_GLOBAL_H
#include <QMutex>
#include <pthread.h>
#include "third_party/kiss_fft/kiss_fftr.h"
#define PROGRAM_NAME "DSRemote"
#define PROGRAM_VERSION "0.35_1707091423"
#define PROGRAM_VERSION "0.35_1707091429"
#define MAX_PATHLEN 4096
@ -245,7 +245,7 @@ struct device_settings
int screenupdates_on;
QMutex *mutexx;
pthread_mutex_t mutexx;
int thread_error_stat;
int thread_error_line;

Wyświetl plik

@ -461,7 +461,8 @@ void UI_Mainwindow::close_connection()
scrn_thread->wait(5000);
devparms.mutexx->unlock();
pthread_mutex_trylock(&devparms.mutexx);
pthread_mutex_unlock(&devparms.mutexx);
scrn_thread->h_busy = 0;
}
@ -2714,21 +2715,21 @@ void UI_Mainwindow::screenUpdate()
if(device == NULL)
{
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
if(!devparms.connected)
{
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
if(!devparms.screenupdates_on)
{
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
@ -2747,7 +2748,7 @@ void UI_Mainwindow::screenUpdate()
msgBox.setText(str);
msgBox.exec();
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
close_connection();
@ -2756,7 +2757,7 @@ void UI_Mainwindow::screenUpdate()
if(devparms.thread_result == TMC_THRD_RESULT_NONE)
{
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
@ -2770,14 +2771,14 @@ void UI_Mainwindow::screenUpdate()
// waveForm->setTrigLineVisible();
}
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
if(scrn_timer->isActive() == false)
{
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
@ -2828,7 +2829,7 @@ void UI_Mainwindow::screenUpdate()
if(waveForm->hasMoveEvent() == true)
{
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
@ -2847,7 +2848,7 @@ void UI_Mainwindow::screenUpdate()
{
waveForm->clear();
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
return;
}
@ -2867,7 +2868,7 @@ void UI_Mainwindow::screenUpdate()
waveForm->update();
}
devparms.mutexx->unlock();
pthread_mutex_unlock(&devparms.mutexx);
}

Wyświetl plik

@ -74,6 +74,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pthread.h>
#include "global.h"
#include "about_dialog.h"

Wyświetl plik

@ -158,7 +158,7 @@ UI_Mainwindow::UI_Mainwindow()
strcpy(devparms.modelname, "-----");
devparms.mutexx = new QMutex();
pthread_mutex_init(&devparms.mutexx, NULL);
scrn_thread = new screen_thread;
scrn_thread->set_device(NULL);
@ -632,7 +632,7 @@ UI_Mainwindow::~UI_Mainwindow()
delete scrn_thread;
delete appfont;
delete monofont;
delete devparms.mutexx;
pthread_mutex_destroy(&devparms.mutexx);
free(devparms.screenshot_buf);

Wyświetl plik

@ -117,7 +117,7 @@ void UI_Mainwindow::adjdial_timer_handler()
void UI_Mainwindow::scrn_timer_handler()
{
if(devparms.mutexx->tryLock() == false)
if(pthread_mutex_trylock(&devparms.mutexx))
{
return;
}