
Anthony Williams wrote: [...]
I might well let the OS clean up such things on process termination, which is fine (assuming it does so), since these are all OS objects. Is that what you had in mind?
Not quite. include <pthread.h> pthread_t mutex = PTHREAD_MUTEX_INITIALIZER; int main() { pthread_mutex_destroy(&mutex); } Is OK.
However, our once_flag can store a result of a user-defined type, which may therefore require proper destruction, so that it can notify other processes, send network packets, write to a file, or whatever; this therefore needs dealing with somehow before process termination.
User would then call _destroy() or _reset() (the later is likely to be called multiple times). I won't tell you "how". Trade secret. regards, alexander.