source: pacpusframework/trunk/src/PacpusTools/src/PeriodicWorker.cpp@ 10

Last change on this file since 10 was 10, checked in by sgosseli, 12 years ago

Add PeriodWorker and provide an example in the documentation.

File size: 536 bytes
Line 
1// Includes, pacpus.
2#include <PacpusTools/PeriodicWorker.h>
3
4// Includes, qt.
5#include <QTimer>
6
7using namespace pacpus;
8
9PeriodicWorker::PeriodicWorker()
10 : AsyncWorkerBase()
11 , mHeartbeat(NULL)
12{
13 mHeartbeat = new QTimer(this);
14}
15
16PeriodicWorker::~PeriodicWorker()
17{
18}
19
20void
21PeriodicWorker::startWork(int msec)
22{
23 mHeartbeat->start(msec);
24 connect(mHeartbeat, SIGNAL(timeout()), this, SLOT(doWork()));
25
26 this->start();
27}
28
29void
30PeriodicWorker::stopWork()
31{
32 disconnect(mHeartbeat, SIGNAL(timeout()), this, SLOT(doWork()));
33}
Note: See TracBrowser for help on using the repository browser.