Project

General

Profile

RE: Can new created thread emit signals to Wt thread usin... » DataSource.cpp

ruliang ge, 05/07/2010 06:46 AM

 
#include "DataSource.h"
#include <stdio.h>

DataSource* DataSource::instance_ = 0;

DataSource* DataSource::getInstance(){
if(instance_ == 0){
instance_ = new DataSource();
}
return instance_;
}

DataSource::DataSource(){
ifStarted_ = false;
dataCounter_ = 0;
}

void DataSource::Start(){
if(ifStarted_){
return;
}
ifStarted_ = true;

while(true){
dataCounter_ ++;
if(dataCounter_ == 200) dataCounter_ = 0;
if(dataCounter_ % 6 == 0){
sendEvent(dataCounter_);
}
}
}

void DataSource::sendEvent(int arg_number){
boost::mutex::scoped_lock lock(mutex_);
sourceEvent_.emit(arg_number);
}
(4-4/4)