#endif // DEBUG
}
-Runnable::Runnable(void): thread(0), stop(false) {
+Runnable::Runnable(void): _thread(NULL), _stop(false) {
#ifdef DEBUG
cerr << __FILE__ << "(" << __LINE__ << ")"
<< ": constructor." << endl;
void Runnable::static_run(Runnable* runner) {
#ifdef DEBUG
cerr << __FILE__ << "(" << __LINE__ << ")"
- << ": static_run(runner = " << runner << ")"
- << endl;
+ << ": static_run(runner = " << runner << ")" << endl;
#endif // DEBUG
runner->real_run();
- runner->finished();
- //runner->thread->join();
+ runner->_finished();
delete runner;
}
if (detach) {
// Corremos el thread en una funcion estática para poder destruirlo al
// finalizar, pasandole el puntero al objeto.
- thread = Glib::Thread::create(
+ _thread = Glib::Thread::create(
SigC::bind<Runnable*>(SigC::slot(&Runnable::static_run), this),
- true);//false);
+ false);//true);
// Si no corremos la tarea normalmente.
} else {
real_run();
}
-void Runnable::finish(bool attach) {
+void Runnable::finish(void) {
#ifdef DEBUG
cerr << __FILE__ << "(" << __LINE__ << ")"
- << ": finish(attach = " << attach << ")" << endl;
+ << ": finish();" << endl;
#endif // DEBUG
- stop = true;
- if (attach) {
- thread->join();
- }
+ stop(true);
+}
+
+bool Runnable::stop(void) {
+ Glib::Mutex::Lock lock(stop_mutex);
+ bool tmp = _stop;
+ return tmp;
+}
+
+bool Runnable::stop(bool stop) {
+ Glib::Mutex::Lock lock(stop_mutex);
+ bool tmp = _stop;
+ _stop = stop;
+ return tmp;
}
Runnable::SignalFinished& Runnable::signal_finished(void) {
- return finished;
+ return _finished;
}
Runnable::SignalError& Runnable::signal_error(void) {
- return error;
+ return _error;
}
} // namespace Server