Subj : Re: double-checked locking in C To : comp.programming.threads From : Joe Seigh Date : Thu Jul 07 2005 02:15 pm Alexander Terekhov wrote: > Joe Seigh wrote: > [...] > >>memcpy() of a static pthread_once_t initialized with PTHREAD_ONCE_INIT >>for pthread_once_init(). > > > Undefined behavior (as soon as you call pthread_once() on a "cloned" > thing). Because pthread_once_t is noncopyable, just like any other > synchronization objects. > > "The behavior of pthread_once() is undefined if once_control has > automatic storage duration or is not initialized by > PTHREAD_ONCE_INIT." > So what kind of value could PTHREAD_ONCE_INIT have that couldn't be memcpy'd from an initialized pthread_once_t object never otherwise used? > >>I don't even know what pthread_once_reset() even means. > > > Effect is the same as pthread_once_destroy()+pthread_once_init() > (with pthread_once_destroy() invoking optional destructor function) > except that it is throw()-nothing operation (vs pthread_once_init() > that can throw). > If C had exceptions. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .