PSQt/src/ThreadTimer.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------
00002 // File and Version Information:
00003 //   $Id: ThreadTimer.cpp 9841 2015-03-26 18:35:44Z dubrovin@SLAC.STANFORD.EDU $
00004 //
00005 // Author: Mikhail S. Dubrovin
00006 //---------------------------------------------------------------------
00007 
00008 
00009 #include "PSQt/ThreadTimer.h"
00010 #include <iostream>
00011 using  namespace std;
00012 
00013 namespace PSQt {
00014 
00015 //--------------------------
00016 
00017   ThreadTimer::ThreadTimer(QObject* parent, unsigned dt_sec, bool pbits)
00018   : QThread(parent)
00019   , m_count(0)
00020   , m_dt_sec(dt_sec)
00021   , m_pbits(pbits)
00022 {
00023   static uint thread_counter = 0; thread_counter++;
00024   m_thread_number = thread_counter;
00025 }
00026 
00027 //--------------------------
00028 
00029 void ThreadTimer::run()
00030 {
00031   do {
00032 
00033     if (m_pbits & 1) cout << " Thread:" << m_thread_number << " loop =" << ++m_count << endl;
00034     sleep(m_dt_sec); 
00035 
00036   } while (true);
00037 }
00038 
00039 //--------------------------
00040 } // namespace PSQt
00041 //--------------------------

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7