??????Linux???????C/C++???ж????????????????????????????????????д???????????????????????????????????????????????????????????????????????????Щ??????????????????????????????????????????????????????????????????????????????????????Щ????????????????????????????????????????????????????????????????????????洢???棬????????????????????????????
???????????????
??????C/C++?????г??????????????????????????????????????????????????????????????????????????????????????Χ??????????????????????????????????????и??????????????????????????????????????д???????????????????????е?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????3????????
????????????????????????????????????????????????????????????????????μ?????????????????Static memory local to a thread (????????????)??????????????????????TSD: Thread-Specific Data????????????洢??TLS: Thread-Local Storage?????????????????????????????????????????????????(copy)???????????????????У??????????????????????????????????

?????????????????
????????????????????????????????????????????????????????????????????????????????????????????Щ?????????????????Ρ????磺??C++???????????????????????????????????????????????????????????£???????????????????????????????????????????????????——?????????????????????????????????Singleton????Linux?????????o???????????????????
????#include <pthread.h>
????// Returns 0 on success?? or a positive error number on error
????int pthread_once (pthread_once_t *once_control?? void (*init) (void));
???????ò???once_control??????????pthread_once()????????????ж?????????????θú?????????????????init??????????????????????init?????????????κβ???????????£?
????void init (void)
????{
????// some variables initializtion in here
????}
????????????once_control??????pthread_once_t????????????????????PTHRAD_ONCE_INIT????????????C++0x??????????????????std::call_once ()???÷???ú????????????????ο?https://github.com/ApusApp/Swift/blob/master/swift/base/singleton.hpp????
?????????????????API
??????Linux?????????o??????????????????в???
#include <pthread.h>
// Returns 0 on success?? or a positive error number on error
int pthread_key_create (pthread_key_t *key?? void (*destructor)(void *));
// Returns 0 on success?? or a positive error number on error
int pthread_key_delete (pthread_key_t key);
// Returns 0 on success?? or a positive error number on error
int pthread_setspecific (pthread_key_t key?? const void *value);
// Returns pointer?? or NULL if no thread-specific data is associated with key
void *pthread_getspecific (pthread_key_t key);
????????pthread_key_create()??????????????????????????key????′???????????????????????????????÷????????????????key???????????????????C++?????????????????????????????????????????????????з???????????????????????pthread_key_t????destructor?????????????????????????????£?
????void Dest (void *value)
????{
????// Release storage pointed to by 'value'
????}
???????????????key??????????NULL????destructor????????????????????á?????????????ж????????洢?????????????????????????destructor??????????????????????????????????destructor????????????????????
????????pthread_key_delete()??????鵱??????????????????????????????????????????????destructor????????????????????ε???pthread_key_create()??á???Linux????У????????????????????????????NULL??
?????????????????????pthread_key_t??????????????????????????в???????????????pthread_key_t??????Linux?п??????PTHREAD_KEY_MAX????????limits.h????У???????????sysconf(_SC_THREAD_KEYS_MAX)???????????????????????Linux???????1024??????????????????????????????????????????ж????????洢????????????????Щ??????????????????У?????????????????????????????????????????????????????á?
$news_page $
????????pthread_setspecific()?????value??????洢?????????У??????????????????key???????????value??????????????????????棬????????????????????????????????key???????destructor????????????????????????е???????洢??????????NULL????????????????????????????pthread_getspecific()?????????????????????key????????????У????pthread_getspecific()??????????沢???pthread_setspecific()????????????????????
????????value??????????????????????????????????????κο??????????void*??????????????????£??????pthread_key_create()??????????? destructor?????NULL??
????????pthread_getspecific()??????pthread_setspecific()?????????pthread_setspecific()?????value??????????????????????void*???????????????????
????????????????????洢????
????1. ?????????????洢??????????????API????á???????????а??????????飺
???????????????????????飬????????????洢???????
????pthread_key_create()?????pthread_key_t???????????????????????????????????pthread_keys????????????£?

???????????????????????????????ε???????????α?????????????????????????????????????????????洢?????????????????????destructor??????
?????????????????????飬??????????????????????????????????????pthread_setspecific()???????洢????????????е?value??
????2. ???????洢pthread_setspecific()????????value??????У?????????????????????????м???pthread_keys[1]?????func1()??????pthread API????????????????????洢???????????????飬?????????????????????????????????(???)?е????pthread_keys????????????

?????塢???
???????????????????????????????????з????????????????????????У???????????????????????????????????????????????????????????????????????????????????????ж?д???????????????????????????????????????Щ????????????????????????????????????????Щ??????????????????????????????????????????????洢?????????????????????????????????Ч?????????????????????????????????????Щ???????????????Linux C++????????洢??????ο?https://github.com/ApusApp/Swift/blob/master/swift/base/threadlocal.h??????????Ч??????ο?Facebook??folly???е?ThreadLocal???????????????????洢?????????__thread??????????????????