X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/ca892569659649f00dee51624d31bced690751f3..212f9ae5dc8899bab8b23ed13d81c28c510db3c3:/Server/src/plant.cpp diff --git a/Server/src/plant.cpp b/Server/src/plant.cpp index b020e21..0e70a1f 100644 --- a/Server/src/plant.cpp +++ b/Server/src/plant.cpp @@ -44,11 +44,20 @@ Plant::~Plant(void) { cerr << __FILE__ << "(" << __LINE__ << ")" << ": destructor." << endl; #endif // DEBUG - // Termino transmisiones. - Glib::Mutex::Lock lock(transmissions_mutex); - for (TransmitterList::iterator trans = transmissions.end(); + // Mando a terminar todas las transmisiones. + transmissions_mutex.lock(); + for (TransmitterList::iterator trans = transmissions.begin(); trans != transmissions.end(); trans++) { - (*trans)->finish(true); + (*trans)->finish(); + } + TransmitterList::size_type count = transmissions.size(); + transmissions_mutex.unlock(); + // Espero que terminen realmente. + while (count) { + Glib::usleep(10000); // 10 milisegundos + transmissions_mutex.lock(); + count = transmissions.size(); + transmissions_mutex.unlock(); } } @@ -76,7 +85,7 @@ void Plant::real_run(void) { cerr << __FILE__ << "(" << __LINE__ << ")" << ": real_run." << endl; #endif // DEBUG - while (!stop) { + while (!stop()) { simulator_mutex.lock(); simulator.simulate(); string plantstatus = simulator.get_state_as_xml(); @@ -87,7 +96,7 @@ void Plant::real_run(void) { (*i)->send(plantstatus); } transmissions_mutex.unlock(); - Glib::usleep(1000000); + Glib::usleep(100000); } }