From: Lyndon Samson Date: 2005-08-24T17:45:36+09:00 Subject: Re: Embedding ruby in a multi-threaded host application ------=_Part_934_5353463.1124872735789 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sometimes Thread Local Storage is a possible work around for global variabl= e=20 issues. With Windows you can achieve this in two different ways:=20 - Declare a variable as thread local=20 Say you have a global variable *int g_TheCounter;*. You can write * _declspec(thread) int g_TheCounter;*. This tells the compiler to tread= =20 the variable as thread local.=20 - Use dynamic thread local storage=20 There is a special API The functions (* TlsAlloc/TlsFree/TlsSetValue/TlsGetValue*).=20 =20 *TlsAlloc/TlsFree* Allocate an index that is used to access one thread= =20 local storage value. This index must be placed into a global variable (i= t is=20 a read only value since). It is used with the *TlsSetValue/TlsGetValue * functions to modify the thread local storage variable. For more=20 details see the Knowlede base article Q94804 "Thread Local Storage overv= iew =20 http://www.michaelmoser.org/tlssupp.htm ------=_Part_934_5353463.1124872735789--