[gephex-devel] gephex--main--0.4--patch-1875

gephex at sonnenland.kexbox.org gephex at sonnenland.kexbox.org
Tue Apr 5 18:58:52 CEST 2005


Archive: gephex at gephex.org--2004
New revision: gephex--main--0.4--patch-1875

--
Revision: gephex--main--0.4--patch-1875
Archive: gephex at gephex.org--2004
Creator: The Gephex Source Archive <gephex at gephex.org>
Date: Tue Apr  5 18:56:24 CEST 2005
Standard-date: 2005-04-05 16:56:24 GMT
New-files: engine/src/engine/.arch-ids/synced_tasks.h.id
    engine/src/engine/synced_tasks.h
Modified-files: engine/src/engine/Makefile.am
    engine/src/engine/controller.cpp
    engine/src/engine/controller.h
New-patches: gephex at gephex.org--2004/gephex--main--0.4--patch-1875
    martin at gephex.org--2004/gephex--martin--0.4--patch-69
Summary: [MERGE-REQUEST] bugfix for #105
Keywords: 

Patches applied:

 * martin at gephex.org--2004/gephex--martin--0.4--patch-69
   fixes timebase for ttl option

* added files

    engine/src/engine/.arch-ids/synced_tasks.h.id
    engine/src/engine/synced_tasks.h
    {arch}/gephex/gephex--main/gephex--main--0.4/gephex at gephex.org--2004/patch-log/patch-1875
    {arch}/gephex/gephex--martin/gephex--martin--0.4/martin at gephex.org--2004/patch-log/patch-69

* modified files

--- orig/engine/src/engine/Makefile.am
+++ mod/engine/src/engine/Makefile.am
@@ -37,7 +37,8 @@
 	controller.h \
 	controller.cpp \
         bufferedsender.h \
-        bufferedsender.cpp
+        bufferedsender.cpp \
+	synced_task.h
 
 gephex_engine_real_LDADD = \
 	-ldllloader \


--- orig/engine/src/engine/controller.cpp
+++ mod/engine/src/engine/controller.cpp
@@ -22,7 +22,6 @@
 
 #include "controller.h"
 #include <iostream>
-
 #if defined (HAVE_CONFIG_H)
 #include "config.h"
 #endif
@@ -94,6 +93,24 @@
   };
 
 
+  auto_stop_task::auto_stop_task(Controller* ctrl, unsigned int ttl)
+    : m_ctrl(ctrl), m_ttl(ttl), m_time(0)
+  {
+  }
+      
+  bool auto_stop_task::run()
+  {
+    ++m_time;
+
+    if (m_ttl != 0)
+      std::cout << m_time << std::endl;
+    
+    if (m_time == m_ttl)
+      m_ctrl->shutDown();
+    return true;
+  }
+
+
 
   /**
    * Returns a vector of all files in a list of paths, that have a certain
@@ -234,7 +251,7 @@
       pDllLoader(logger),
       first_time(true),
       ttl(config.get_int_param("ttl")),
-      time(0)
+      auto_stop(this,ttl)
   {
     
     net::IServerSocket* serverSocket;
@@ -338,7 +355,15 @@
     scheduler.addTask(*acceptor, 500);
     scheduler.addTask(*this,250);
     scheduler.addTask(netPoller,netInterval);
-    scheduler.addTask(pRenderer,rendererInterval);
+
+    std::list<ITask*> t_list;
+    t_list.push_back(&auto_stop);
+    t_list.push_back(&pRenderer);
+    
+    augmented_render_task =
+      utils::AutoPtr<synced_tasks>(new synced_tasks(t_list));
+    
+    scheduler.addTask(*augmented_render_task,rendererInterval);
 
 	
     // load stuff
@@ -459,11 +484,6 @@
   
   bool Controller::run()
   {
-    ++time;
-
-    if ( ttl != 0  &&  time == ttl )
-      shutDown();
-    
     try 
       {
         // here comes what happens after the connection to the gui is


--- orig/engine/src/engine/controller.h
+++ mod/engine/src/engine/controller.h
@@ -59,6 +59,7 @@
 #include "renderer.h"
 #include "dllloader.h"
 #include "scheduler.h"
+#include "synced_tasks.h"
 
 #include "configmanager.h"
 
@@ -78,7 +79,19 @@
   class AutoTypeLoader;
   class AutoModuleLoader;
   class Acceptor;
+  class Controller;
 
+  class auto_stop_task: public ITask
+    {
+    public:
+      auto_stop_task(Controller* ctrl, unsigned int ttl);
+      bool run();
+    private:
+      Controller* m_ctrl;
+      unsigned int m_time;
+      unsigned int m_ttl;
+    };
+  
   class NetPoller : public ITask
     {
     public:
@@ -179,11 +192,12 @@
 	
       utils::AutoPtr<AutoTypeLoader> sf;
       utils::AutoPtr<AutoModuleLoader> aml;
+      utils::AutoPtr<synced_tasks> augmented_render_task;
       engine::Scheduler scheduler;
 
       bool first_time;
-      unsigned int time;
       unsigned int ttl;
+      auto_stop_task auto_stop;
     };
 
 }



More information about the gephex-devel mailing list