+// vim: set noexpandtab tabstop=4 shiftwidth=4:
+//----------------------------------------------------------------------------
+// PlaQui
+//----------------------------------------------------------------------------
+// This file is part of PlaQui.
+//
+// PlaQui is free software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the Free Software
+// Foundation; either version 2 of the License, or (at your option) any later
+// version.
+//
+// PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+// details.
+//
+// You should have received a copy of the GNU General Public License along
+// with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple
+// Place, Suite 330, Boston, MA 02111-1307 USA
+//----------------------------------------------------------------------------
+// Creado: dom oct 19 01:13:33 ART 2003
+// Autores: Leandro Lucarella <llucare@fi.uba.ar>
+//----------------------------------------------------------------------------
+//
+// $Id$
+//
+
+#include "runnable.h"
+#include <sigc++/class_slot.h>
+#include <glibmm/thread.h>
+#ifdef DEBUG
+# include <iostream>
+#endif // DEBUG
+
+using namespace Plaqui;
+
+Runnable::Runnable(void): thread(0) {
+}
+
+void Runnable::run(bool detach) {
+#ifdef DEBUG
+ std::cerr << __FILE__ << ": 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.
+ thread = Glib::Thread::create(
+ SigC::slot_class(*this, &Runnable::real_run), true);
+ // Si no corremos la tarea normalmente.
+ } else {
+ real_run();
+ }
+
+}
+