c++ - Thread-Local storage and iOS -
my understanding ios not support __thread. there is, obviously, way using pthread_setspecific. however, there template class has implemented functionality?
i'd ate re-invent wheel, won't simple piece of code write.
any links hugely appreciated!
cheers
foundation provides -[nsthread threaddictionary]. can use store thread-local objective-c objects, include nsvalue wrapping address of dynamic storage.
note cocoa moving towards thread-blind execution of threaded code, submit blocks of code run on available system-owned thread. model used grand central dispatch , shared nsoperationqueues. code relying on thread-local storage not make best use of model. see apple's concurrency programming guide more info.
eta: starting ios 5 / os x 10.7, grand central dispatch gained call queue-local storage via dispatch_queue_set_specific, dispatch_queue_get_specific, , dispatch_get_specific functions. setter allows supply destructor function in addition value when set new value key or when queue destroyed. getter sans queue uses current queue context, , repeat lookup on current queue's target queue if key not defined on current queue (similar how property lookup in prototypal oo system works).
Comments
Post a Comment