Browse Source

fix that warteAufThread immediatly returns without waiting the specified amound of time on linux systems

Kolja Strohm 1 year ago
parent
commit
3fb7ab6f48
4 changed files with 15 additions and 5 deletions
  1. 8 2
      Framework Linux.vcxproj
  2. BIN
      Framework Tests/Framwork.dll
  3. 4 1
      Globals.h
  4. 3 2
      Thread.cpp

+ 8 - 2
Framework Linux.vcxproj

@@ -57,6 +57,7 @@
     <UseDebugLibraries>true</UseDebugLibraries>
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <RemoteRootDir>/home/kolja/projects</RemoteRootDir>
+    <RemoteProjectRelDir>/home/kolja/projects/Framework/debug/</RemoteProjectRelDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
     <UseDebugLibraries>false</UseDebugLibraries>
@@ -82,10 +83,13 @@
     <RemoteProjectDir>$(RemoteRootDir)/Framework/debug</RemoteProjectDir>
     <TargetName>libdbgFramework</TargetName>
     <IncludePath>$(IncludePath)</IncludePath>
-    <OutDir>$(RemoteRootDir)/Framework/debug/</OutDir>
-    <IntDir>$(RemoteRootDir)/Framework/debug/</IntDir>
+    <OutDir>/home/kolja/projects/Framework/debug/</OutDir>
+    <IntDir>/home/kolja/projects/Framework/debug/</IntDir>
     <RemoteTargetPath>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</RemoteTargetPath>
     <RemoteLinkLocalCopyOutput>true</RemoteLinkLocalCopyOutput>
+    <RemoteIntRelDir>/home/kolja/projects/Framework/debug/</RemoteIntRelDir>
+    <RemoteOutRelDir>/home/kolja/projects/Framework/debug/</RemoteOutRelDir>
+    <RemoteDeployDir>/home/kolja/projects/Framework/debug/</RemoteDeployDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <TargetExt>.so</TargetExt>
@@ -259,6 +263,8 @@
       <CppAdditionalWarning>switch;no-deprecated-declarations;empty-body;conversion;return-type;parentheses;no-format;uninitialized;unreachable-code;unused-function;unused-value;unused-variable;%(CppAdditionalWarning)</CppAdditionalWarning>
       <AdditionalOptions>-fPIC -Wno-unknown-pragmas</AdditionalOptions>
       <PositionIndependentCode>true</PositionIndependentCode>
+      <ObjectFileName>%(filename).o</ObjectFileName>
+      <CppLanguageStandard>c++17</CppLanguageStandard>
     </ClCompile>
     <Link>
       <AdditionalDependencies>$(StlAdditionalDependencies)</AdditionalDependencies>

BIN
Framework Tests/Framwork.dll


+ 4 - 1
Globals.h

@@ -3,7 +3,10 @@
 
 #include "Critical.h"
 #include "Punkt.h"
-#include "Maus.h"
+
+#ifdef WIN32
+#    include "Maus.h"
+#endif
 
 #ifndef Global
 #    define Global extern

+ 3 - 2
Thread.cpp

@@ -112,8 +112,9 @@ int Thread::warteAufThread(int zeit) // wartet zeit lang auf den Thread
     if (!run) return 0;
     if (pthread_self() == threadHandle) return 0;
     timespec ts;
-    ts.tv_sec = 0;
-    ts.tv_nsec = 1000 * zeit;
+    if (clock_gettime(CLOCK_REALTIME, &ts) == -1) return -1;
+    ts.tv_sec += (zeit + ts.tv_nsec / 1000) / 1000;
+    ts.tv_nsec = 1000 * ((zeit + ts.tv_nsec / 1000) % 1000);
     if (threadHandleSys) *threadHandleSys = 0;
     int ret = pthread_timedjoin_np(threadHandle, 0, &ts);
     if (!ret)