git-svn-id: svn://db.shs.com.ru/pip@660 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2018-11-16 21:42:07 +00:00
parent ce0e95ad90
commit 9145680e0d
2 changed files with 72 additions and 25 deletions

View File

@@ -148,13 +148,14 @@ public:
private:
class Pool: public PIThread {
public:
Pool();
~Pool();
static Pool * instance();
void add(_PITimerImp_Pool * t);
void remove(_PITimerImp_Pool * t);
void run();
PIVector<_PITimerImp_Pool * > timers, to_remove;
private:
explicit Pool();
virtual ~Pool();
};
virtual bool startTimer(double interval_ms);
virtual bool stopTimer(bool wait);
@@ -390,7 +391,7 @@ _PITimerImp_Pool::Pool * _PITimerImp_Pool::Pool::instance() {
void _PITimerImp_Pool::Pool::add(_PITimerImp_Pool * t) {
//piCout << "add ...";
lock();
to_remove.removeOne(t);
to_remove.removeAll(t);
if (!timers.contains(t))
timers << t;
unlock();
@@ -408,14 +409,13 @@ void _PITimerImp_Pool::Pool::remove(_PITimerImp_Pool * t) {
void _PITimerImp_Pool::Pool::run() {
piForeach (_PITimerImp_Pool * t, timers)
t->threadFunc();
if (!to_remove.isEmpty()) {
piForeach (_PITimerImp_Pool * t, to_remove)
timers.removeOne(t);
timers.removeAll(t);
to_remove.clear();
}
//while (t->threadFunc());
piForeach (_PITimerImp_Pool * t, timers)
t->threadFunc();
}
@@ -428,6 +428,9 @@ bool _PITimerImp_Pool::startTimer(double interval_ms) {
bool _PITimerImp_Pool::stopTimer(bool wait) {
Pool::instance()->remove(this);
// if (wait) {
// Pool::instance()->waitForDelete(this);
// }
return true;
}