浏览代码

Fixed thread registration issue.

woollybah 5 年之前
父节点
当前提交
7c4881449b
共有 3 个文件被更改,包括 19 次插入9 次删除
  1. 1 1
      steamsdk.mod/common.bmx
  2. 12 4
      steamsdk.mod/glue/glue.cpp
  3. 6 4
      steamsdk.mod/steamsdk.bmx

+ 1 - 1
steamsdk.mod/common.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2019 Bruce A Henderson
+' Copyright (c) 2019-2020 Bruce A Henderson
 ' 
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages

+ 12 - 4
steamsdk.mod/glue/glue.cpp

@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2019 Bruce A Henderson
+  Copyright (c) 2019-2020 Bruce A Henderson
   
   This software is provided 'as-is', without any express or implied
   warranty. In no event will the authors be held liable for any damages
@@ -367,6 +367,7 @@ class CallbackTimer
 {
     std::thread th;
     bool running = false;
+	BBThread * bbThread = NULL;
 
 public:
     typedef std::chrono::milliseconds Interval;
@@ -376,13 +377,20 @@ public:
         running = true;
 
         th = std::thread([=]() {
-			struct GC_stack_base base;;
-			GC_get_stack_base(&base);
-			GC_register_my_thread(&base);
+
+#ifdef _WIN32
+			auto nativeThread = ::GetCurrentThreadId();
+#else
+			auto nativeThread = pthread_self();
+#endif
+			bbThread = bbThreadRegister(nativeThread);
+
             while (running) {
                 std::this_thread::sleep_for(interval);
                 timeout();
             }
+
+			bbThreadUnregister(bbThread);
         });
     }
 

+ 6 - 4
steamsdk.mod/steamsdk.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2019 Bruce A Henderson
+' Copyright (c) 2019-2020 Bruce A Henderson
 ' 
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
@@ -21,13 +21,15 @@ SuperStrict
 Rem
 bbdoc: Steam SDK
 End Rem
-Module steam.steamsdk
+Module Steam.SteamSDK
 
-ModuleInfo "Version: 1.02"
+ModuleInfo "Version: 1.03"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Steam SDK - Valve Corporation"
-ModuleInfo "Copyright: Wrapper - 2019 Bruce A Henderson"
+ModuleInfo "Copyright: Wrapper - 2019-2020 Bruce A Henderson"
 
+ModuleInfo "History: 1.03"
+ModuleInfo "History: Fixed thread registration."
 ModuleInfo "History: 1.02"
 ModuleInfo "History: Added ISteamFriends API."
 ModuleInfo "History: 1.01"