Jelajahi Sumber

Added definition for threaded variables.

Brucey 4 tahun lalu
induk
melakukan
16f0976da8
2 mengubah file dengan 8 tambahan dan 0 penghapusan
  1. 6 0
      blitz.mod/blitz.bmx
  2. 2 0
      blitz.mod/blitz_thread.h

+ 6 - 0
blitz.mod/blitz.bmx

@@ -871,6 +871,12 @@ bbdoc: Declare a global variable
 keyword: "Global"
 End Rem
 
+Rem
+bbdoc: Declare a threaded global variable
+about: Each thread will have its own copy of the variable - any changes to the variable will be visible only within the thread the change was made.
+keyword: "ThreadedGlobal"
+End Rem
+
 Rem
 bbdoc: Declare a field variable
 keyword: "Field"

+ 2 - 0
blitz.mod/blitz_thread.h

@@ -149,6 +149,8 @@ extern bb_mutex_t _bbLock;
 #define BB_LOCK if( _bbNeedsLock ){ bb_mutex_lock( &_bbLock ); }
 #define BB_UNLOCK if( _bbNeedsLock ){ bb_mutex_unlock( &_bbLock ); }
 
+#define BBThreadLocal __thread
+
 #ifdef __cplusplus
 }
 #endif