单例模式 Single mode

我觉得Posix下比较好的一种方式

int pthread_once(pthread_once_t *once_control, void (*init_routine) (void));

功能:本函数使用初值为PTHREAD_ONCE_INIT的once_control变量保证init_routine()函数在本进程执行序列中仅执行一次。

posted @ 2015-07-15 22:39  朽木可雕否  阅读(217)  评论(0编辑  收藏  举报