QXRD  0.11.16
qxrdfilebrowsermodelupdaterthread.cpp
Go to the documentation of this file.
1 #include "qxrddebug.h"
3 #include "qxrdfilebrowsermodel.h"
5 #include "qxrdapplication.h"
6 #include "qcepmutexlocker.h"
7 
9  QxrdThread(),
10  m_Model(),
11  m_Updater()
12 {
14  printf("QxrdFileBrowserModelUpdaterThread::QxrdFileBrowserModelUpdaterThread(%p)\n", this);
15  }
16 
17  setObjectName("updater");
18 }
19 
21 {
22  shutdown();
23 
25  printf("QxrdFileBrowserModelUpdaterThread::~QxrdFileBrowserModelUpdaterThread(%p)\n", this);
26  }
27 }
28 
30 {
31  m_Model = model;
32 }
33 
35 {
36 // INVOKE_CHECK(QMetaObject::invokeMethod(m_Updater.data(),"shutdown",Qt::QueuedConnection));
37  exit();
38 
39  wait();
40 }
41 
43 {
44  if (qcepDebug(DEBUG_THREADS)) {
45  printf("Browser Model Updater Thread Started\n");
46  }
47 
51 
52  int rc = -1;
53 
54  if (p) {
55  m_Mutex.lock();
56  m_Updater = p;
57  m_Mutex.unlock();
58 
59  rc = exec();
60  }
61 
62  {
63  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
64 
66  }
67 
68  if (qcepDebug(DEBUG_THREADS)) {
69  printf("Browser Model Updater Thread Terminated with rc %d\n", rc);
70  }
71 }
72 
74 {
75  while (isRunning()) {
76  {
77  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
78 
79  if (m_Updater) return m_Updater;
80  }
81 
82  QThread::msleep(50);
83  }
84 
86 }
void setModel(QxrdFileBrowserModelWPtr model)
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QxrdFileBrowserModelUpdaterPtr updater() const
QSharedPointer< QxrdFileBrowserModelUpdater > QxrdFileBrowserModelUpdaterPtr
QMutex m_Mutex
Definition: qcepthread.h:17
QWeakPointer< QxrdFileBrowserModel > QxrdFileBrowserModelWPtr