QXRD  0.11.16
qxrddataprocessorthread.cpp
Go to the documentation of this file.
1 #include "qxrddebug.h"
3 
4 #include "qxrddataprocessor.h"
5 #include "qxrdapplication.h"
6 #include "qxrdexperiment.h"
7 #include "qcepmutexlocker.h"
8 
12  QcepAllocatorWPtr allocator,
13  QxrdFileSaverWPtr filesaver)
14  : QxrdThread(),
15  m_Allocator(allocator),
16  m_FileSaver(filesaver),
17  m_Acquisition(acq),
18  m_Experiment(doc),
19  m_Saver(saver),
20  m_DataProcessor(NULL)
21 {
23  printf("QxrdDataProcessorThread::QxrdDataProcessorThread(%p)\n", this);
24  }
25 
26  setObjectName("processor");
27 }
28 
30 {
31  shutdown();
32 
34  printf("QxrdDataProcessorThread::~QxrdDataProcessorThread(%p)\n", this);
35  }
36 }
37 
39 {
40  if (qcepDebug(DEBUG_THREADS)) {
41  printf("Processor Thread Started\n");
42  }
43 
48  m_FileSaver));
49 
50  int rc = -1;
51 
52  if (p) {
53  p -> initialize();
54 
55  m_Mutex.lock();
56  m_DataProcessor = p;
57  m_Mutex.unlock();
58 
59  rc = exec();
60  }
61 
62 
63  {
64  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
65 
67  }
68 
69  if (qcepDebug(DEBUG_THREADS)) {
70  printf("Processor Thread Terminated with rc %d\n", rc);
71  }
72 }
73 
75 {
76  exit();
77 
78  wait();
79 }
80 
82 {
83  while (isRunning()) {
84  {
85  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
86 
87  if (m_DataProcessor) return m_DataProcessor;
88  }
89 
90  QThread::msleep(50);
91  }
92 
93  return QxrdDataProcessorPtr();
94 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QSharedPointer< QxrdDataProcessor > QxrdDataProcessorPtr
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
QxrdDataProcessorPtr m_DataProcessor
QxrdDataProcessorPtr dataProcessor() const
QWeakPointer< QxrdFileSaver > QxrdFileSaverWPtr
QWeakPointer< QcepAllocator > QcepAllocatorWPtr
QMutex m_Mutex
Definition: qcepthread.h:17
QxrdDataProcessorThread(QcepSettingsSaverWPtr saver, QxrdExperimentWPtr doc, QxrdAcquisitionWPtr acq, QcepAllocatorWPtr allocator, QxrdFileSaverWPtr filesaver)
QxrdAcquisitionWPtr m_Acquisition
QcepSettingsSaverWPtr m_Saver
QWeakPointer< QxrdAcquisition > QxrdAcquisitionWPtr
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr