X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/00cffd5f7c35a915c09d55e6292775e9e01bdeec..f6e29f2008bf5f440000fb647a4782136929c1a1:/Server/src/runnable.cpp diff --git a/Server/src/runnable.cpp b/Server/src/runnable.cpp index 0c6b477..cb3ba6f 100644 --- a/Server/src/runnable.cpp +++ b/Server/src/runnable.cpp @@ -34,7 +34,8 @@ PlaQui::Server::Runnable::~Runnable(void) { #ifdef DEBUG - std::cerr << __FILE__ << ": destructor." << std::endl; + std::cerr << __FILE__ << ": destructor(this = " << this << ")" + << std::endl; #endif // DEBUG } @@ -44,9 +45,10 @@ PlaQui::Server::Runnable::Runnable(void): thread(0), stop(false) { #endif // DEBUG } -void PlaQui::Server::Runnable::static_run(PlaQui::Server::Runnable* runner) { +void PlaQui::Server::Runnable::static_run(Runnable* runner) { #ifdef DEBUG - std::cerr << __FILE__ << ": runner = " << runner << std::endl; + std::cerr << __FILE__ << ": static_run(runner = " << runner << ")" + << std::endl; #endif // DEBUG runner->real_run(); runner->signal_finished().emit(); @@ -55,20 +57,14 @@ void PlaQui::Server::Runnable::static_run(PlaQui::Server::Runnable* runner) { void PlaQui::Server::Runnable::run(bool detach) { #ifdef DEBUG - std::cerr << __FILE__ << ": detach = " << detach << std::endl; + std::cerr << __FILE__ << ": run(detach = " << detach << ")" << std::endl; #endif // DEBUG // Si vamos a correr la tarea en un thread. if (detach) { - // Nos aseguramos de tener threads. - if (!Glib::thread_supported()) { - Glib::thread_init(); - } // Corremos el thread en una funcion estática para poder destruirlo al // finalizar, pasandole el puntero al objeto. thread = Glib::Thread::create( - SigC::bind( - SigC::slot(&PlaQui::Server::Runnable::static_run), - this), + SigC::bind(SigC::slot(&Runnable::static_run), this), true); // Si no corremos la tarea normalmente. } else { @@ -79,9 +75,8 @@ void PlaQui::Server::Runnable::run(bool detach) { void PlaQui::Server::Runnable::finish(bool attach) { #ifdef DEBUG - std::cerr << __FILE__ << ": attach = " << attach << std::endl; + std::cerr << __FILE__ << ": finish(attach = " << attach << ")" << std::endl; #endif // DEBUG - // TODO - necesita un mutex? stop = true; if (attach) { thread->join();