mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Reenable multithreading, and add LoadSummary multithreading
This commit is contained in:
parent
f940064482
commit
777c3aa98a
@ -1,4 +1,4 @@
|
||||
/* SleepLib PRS1 Loader Implementation
|
||||
/* SleepLib PRS1 Loader Implementation
|
||||
*
|
||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||
*
|
||||
@ -2869,9 +2869,9 @@ void PRS1Import::run()
|
||||
session->UpdateSummaries();
|
||||
|
||||
// Save is not threadsafe
|
||||
loader->saveMutex.lock();
|
||||
// loader->saveMutex.lock();
|
||||
session->Store(mach->getDataPath());
|
||||
loader->saveMutex.unlock();
|
||||
// loader->saveMutex.unlock();
|
||||
|
||||
// Unload them from memory
|
||||
session->TrashEvents();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* SleepLib ResMed Loader Implementation
|
||||
/* SleepLib ResMed Loader Implementation
|
||||
*
|
||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||
*
|
||||
@ -1071,10 +1071,10 @@ void ResmedImport::run()
|
||||
// Update indexes, process waveform and perform flagging
|
||||
sess->UpdateSummaries();
|
||||
|
||||
// Save is not threadsafe
|
||||
loader->saveMutex.lock();
|
||||
// Save is not threadsafe?
|
||||
// loader->saveMutex.lock();
|
||||
sess->Store(mach->getDataPath());
|
||||
loader->saveMutex.unlock();
|
||||
// loader->saveMutex.unlock();
|
||||
|
||||
// Free the memory used by this session
|
||||
sess->TrashEvents();
|
||||
@ -1235,9 +1235,9 @@ void ResmedImportStage2::run()
|
||||
}
|
||||
|
||||
loader->addSession(sess);
|
||||
loader->saveMutex.lock();
|
||||
//loader->saveMutex.lock();
|
||||
sess->Store(mach->getDataPath());
|
||||
loader->saveMutex.unlock();
|
||||
//loader->saveMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
@ -3285,8 +3285,6 @@ void ResInitModelMap()
|
||||
resmed_codes[CPAP_PressureMin].push_back("Pression min.");
|
||||
resmed_codes[CPAP_PressureMin].push_back("Min tryck");
|
||||
|
||||
|
||||
|
||||
// SAD file
|
||||
resmed_codes[OXI_Pulse].push_back("Pulse.1s");
|
||||
resmed_codes[OXI_SPO2].push_back("SpO2.1s");
|
||||
@ -3309,12 +3307,6 @@ void ResInitModelMap()
|
||||
resmed_codes[RMS9_SetPressure].push_back("S.C.Press");
|
||||
|
||||
resmed_codes[RMS9_EPRLevel].push_back("S.EPR.Level");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ChannelID ResmedLoader::CPAPModeChannel() { return RMS9_Mode; }
|
||||
|
@ -794,14 +794,14 @@ void SaveThread::run()
|
||||
while (running) {
|
||||
Session *sess = machine->popSaveList();
|
||||
if (sess) {
|
||||
if (machine->m_donetasks % 10 == 0) {
|
||||
if (machine->m_donetasks % 20 == 0) {
|
||||
int i = (float(machine->m_donetasks) / float(machine->m_totaltasks) * 100.0);
|
||||
emit UpdateProgress(i);
|
||||
}
|
||||
sess->UpdateSummaries();
|
||||
machine->saveMutex.lock();
|
||||
//machine->saveMutex.lock();
|
||||
sess->Store(path);
|
||||
machine->saveMutex.unlock();
|
||||
//machine->saveMutex.unlock();
|
||||
|
||||
sess->TrashEvents();
|
||||
} else {
|
||||
@ -841,33 +841,33 @@ void SaveTask::run()
|
||||
|
||||
void Machine::queTask(ImportTask * task)
|
||||
{
|
||||
// Okay... what was this turned off???
|
||||
if (AppSetting->multithreading()) {
|
||||
m_tasklist.push_back(task);
|
||||
return;
|
||||
}
|
||||
|
||||
// Not multithreading, run it right now...
|
||||
task->run();
|
||||
return;
|
||||
}
|
||||
|
||||
void Machine::runTasks()
|
||||
{
|
||||
if (0) { //!p_profile->session->multithreading()) {
|
||||
if (0) { //!AppSetting->multithreading()) {
|
||||
Q_ASSERT(m_tasklist.isEmpty());
|
||||
return;
|
||||
}
|
||||
QThreadPool * threadpool = QThreadPool::globalInstance();
|
||||
int m_totaltasks=m_tasklist.size();
|
||||
// int m_totaltasks=m_tasklist.size();
|
||||
int m_currenttask=0;
|
||||
while (!m_tasklist.isEmpty()) {
|
||||
if (threadpool->tryStart(m_tasklist.at(0))) {
|
||||
m_tasklist.pop_front();
|
||||
float f = float(m_currenttask) / float(m_totaltasks) * 100.0;
|
||||
qprogress->setValue(f);
|
||||
// float f = float(m_currenttask) / float(m_totaltasks) * 100.0;
|
||||
// qprogress->setValue(f);
|
||||
m_currenttask++;
|
||||
}
|
||||
QApplication::processEvents();
|
||||
//QApplication::processEvents();
|
||||
}
|
||||
QThreadPool::globalInstance()->waitForDone(-1);
|
||||
}
|
||||
@ -887,6 +887,23 @@ bool Machine::hasModifiedSessions()
|
||||
const QString summaryFileName = "Summaries.xml";
|
||||
const int summaryxml_version=1;
|
||||
|
||||
class LoadTask:public ImportTask
|
||||
{
|
||||
public:
|
||||
LoadTask(Session * s, Machine * m): sess(s), mach(m) {}
|
||||
virtual ~LoadTask() {}
|
||||
virtual void run();
|
||||
|
||||
protected:
|
||||
Session * sess;
|
||||
Machine * mach;
|
||||
};
|
||||
|
||||
void LoadTask::run()
|
||||
{
|
||||
sess->LoadSummary();
|
||||
}
|
||||
|
||||
bool Machine::LoadSummary(QProgressBar * progress)
|
||||
{
|
||||
QTime time;
|
||||
@ -997,17 +1014,21 @@ bool Machine::LoadSummary(QProgressBar * progress)
|
||||
|
||||
progress->setMaximum(sess_order.size());
|
||||
for (it = sess_order.begin(); it != it_end; ++it, ++cnt) {
|
||||
if ((cnt % 100) == 0) {
|
||||
//
|
||||
/* if ((cnt % 100) == 0) {
|
||||
progress->setValue(cnt);
|
||||
//QApplication::processEvents();
|
||||
}
|
||||
} */
|
||||
Session * sess = it.value();
|
||||
if (!AddSession(sess)) {
|
||||
delete sess;
|
||||
} else {
|
||||
if (loadSummaries) sess->LoadSummary();
|
||||
if (loadSummaries) {
|
||||
queTask(new LoadTask(sess,this));
|
||||
}
|
||||
}
|
||||
}
|
||||
runTasks();
|
||||
progress->setValue(sess_order.size());
|
||||
QApplication::processEvents();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* SleepLib Machine Loader Class Implementation
|
||||
/* SleepLib Machine Loader Class Implementation
|
||||
*
|
||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||
*
|
||||
@ -171,8 +171,7 @@ void MachineLoader::queTask(ImportTask * task)
|
||||
|
||||
void MachineLoader::runTasks(bool threaded)
|
||||
{
|
||||
//debug
|
||||
threaded=false;
|
||||
threaded=AppSetting->multithreading();
|
||||
|
||||
m_totaltasks=m_tasklist.size();
|
||||
m_currenttask=0;
|
||||
@ -188,6 +187,7 @@ void MachineLoader::runTasks(bool threaded)
|
||||
}
|
||||
} else {
|
||||
QThreadPool * threadpool = QThreadPool::globalInstance();
|
||||
|
||||
while (!m_tasklist.isEmpty()) {
|
||||
if (threadpool->tryStart(m_tasklist.at(0))) {
|
||||
m_tasklist.pop_front();
|
||||
@ -195,8 +195,10 @@ void MachineLoader::runTasks(bool threaded)
|
||||
qprogress->setValue(f);
|
||||
m_currenttask++;
|
||||
}
|
||||
if ((m_currenttask % 50)==0) {
|
||||
QApplication::processEvents();
|
||||
}
|
||||
}
|
||||
QThreadPool::globalInstance()->waitForDone(-1);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
qprogress->setMaximum(100);
|
||||
qstatus = new QLabel("", this);
|
||||
qprogress->hide();
|
||||
ui->statusbar->setMinimumWidth(200);
|
||||
//ui->statusbar->setMinimumWidth(200);
|
||||
ui->statusbar->addPermanentWidget(qstatus, 0);
|
||||
ui->statusbar->addPermanentWidget(qprogress, 1);
|
||||
|
||||
@ -502,7 +502,7 @@ void MainWindow::OpenProfile(QString profileName)
|
||||
overview->ReloadGraphs();
|
||||
|
||||
// Should really create welcome and statistics here, but they need redoing later anyway to kill off webkit
|
||||
ui->tabWidget->setCurrentWidget(ui->welcomeTab);
|
||||
ui->tabWidget->setCurrentIndex(AppSetting->openTabAtStart());
|
||||
GenerateStatistics();
|
||||
PopulatePurgeMenu();
|
||||
|
||||
|
@ -1454,8 +1454,8 @@ QToolBox::tab:selected {
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>175</width>
|
||||
<height>680</height>
|
||||
<width>158</width>
|
||||
<height>676</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
@ -1913,7 +1913,7 @@ border: 2px solid #56789a; border-radius: 30px;
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>175</width>
|
||||
<height>680</height>
|
||||
<height>667</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
@ -3061,7 +3061,7 @@ border-radius: 10px;
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>175</width>
|
||||
<height>680</height>
|
||||
<height>667</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
@ -3250,7 +3250,7 @@ border-radius: 10px;
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>7</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
|
Loading…
Reference in New Issue
Block a user