[email protected] 8 years ago
parent
commit
97c1822b81
2 changed files with 22 additions and 10 deletions
  1. 11 5
      oxygine/src/AsyncTask.h
  2. 11 5
      oxygine/src/core/log.cpp

+ 11 - 5
oxygine/src/AsyncTask.h

@@ -71,13 +71,19 @@ namespace oxygine
             if (_mainThreadSync)
             {
                 if (addref)
-                    addRef();
-                core::getMainThreadDispatcher().postCallback([ = ]()
                 {
-                    f();
-                    if (addref)
+                    addRef();
+                    core::getMainThreadDispatcher().postCallback([ = ]()
+                    {
+                        f();
                         releaseRef();
-                });
+                    });
+                }
+                else
+                {
+                    core::getMainThreadDispatcher().postCallback(f);
+                }
+
                 return;
             }
             f();

+ 11 - 5
oxygine/src/core/log.cpp

@@ -4,7 +4,7 @@
 #include <stdarg.h>
 #include <string.h>
 #include "utils/stringUtils.h"
-
+#include "oxygine.h"
 
 
 
@@ -41,6 +41,12 @@ namespace oxygine
 
     namespace log
     {
+        int64 startTime = getTimeUTCMS();
+        int getTime()
+        {
+            return getTimeUTCMS() - startTime;
+        }
+
         void enable()
         {
             _enabled = true;
@@ -133,7 +139,7 @@ namespace oxygine
         void message_va(const char* format, va_list args)
         {
             char tm[16];
-            safe_sprintf(tm, "%03d", getTimeMS());
+            safe_sprintf(tm, "%03d", getTime());
             out_prefix(0, tm, format, args);
         }
 
@@ -148,7 +154,7 @@ namespace oxygine
         void warning_va(const char* format, va_list args)
         {
             char tm[32];
-            safe_sprintf(tm, "%03d warning: ", getTimeMS());
+            safe_sprintf(tm, "%03d warning: ", getTime());
 
             out_line_prefix(0, tm, format, args);
         }
@@ -164,7 +170,7 @@ namespace oxygine
         void error_va(const char* format, va_list args)
         {
             char tm[32];
-            safe_sprintf(tm, "%03d error: ", getTimeMS());
+            safe_sprintf(tm, "%03d error: ", getTime());
             out_line_prefix(_eh, tm, format, args);
         }
 
@@ -179,7 +185,7 @@ namespace oxygine
         void messageln_va(const char* format, va_list args)
         {
             char tm[16];
-            safe_sprintf(tm, "%03d ", getTimeMS());
+            safe_sprintf(tm, "%03d ", getTime());
             out_line_prefix(0, tm, format, args);
         }
     }