I am having some problems with the appearance of incorrect pthread_getspecific results in a library that is designed to communicate in various iOS applications.
I see that Apple writes :
Cocoa and POSIX store the thread dictionary differently, so you cannot mix and match calls with the two technologies. However, if you stick to the same technology inside your stream code, the end results should be similar. In Cocoa, you use the threadDictionary method of an NSThread object to retrieve an NSMutableDictionary object to which you can add any keys needed for your thread. On POSIX, you use the special functions pthread_setspecific and pthread_gets to set and retrieve the keys and values ββof your thread.
Does this mean that you canβt expect that the Cocoa and POSIX TLS functions will work in the library code if we donβt know if the code that calls us uses this or that?
How can I get reliable storage and a local stream pointer in these circumstances?
Is there a native Darwin TLS support API that we should use instead of Cocoa or POSIX?
source share