FLS vs TLS, can I use Fiber local storage instead of TLS?

I have portable TLS (thread local storage) code in my library for win-threads and pthreads, but the TlsXXX api is not available in WinRT. However, there is a FlsXXX api that accomplishes almost the same purpose as the TLS api . From MSDN:

A fiber can use local storage (FLS) to create a unique copy of a variable for each fiber. If fiber switching does not occur, FLS acts just like a local thread store

So does this mean that I can just use the FlsXXX api as a replacement for replacement (I don't use fibers, and I don't use __thread specifiers for variables, I use api directly).

+4
source share
1 answer

First you need to convert the stream to fiber.

What you cannot do in the Store app is a good chicken and egg problem. This is what the SDK reports, but it's not really what Microsoft CRT does, it uses FlsAlloc (), but never calls ConvertThreadToFiber / Ex () anywhere. So you're fine, just don't call CreateFiber ().

And yes, FLS is identical to TLS unless you create fibers according to the SDK :

(FLS) . , FLS , . FLS (FlsAlloc, FlsFree, FlsGetValue FlsSetValue) FLS, . , FLS .

, , CRT, VS2012 + vc/crt/src/Platform.cpp, __TlsAlloc(). , FlsAlloc, _CRT_APP #defined. VCLibs, , Store.

, , .

+6

All Articles