$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: tneumann_at_[hidden]
Date: 2001-08-01 02:16:44
> POSIX uses pthread_once to do this,
> but there's no Win32 equivalent. Instead, Win32 programmers are
> expected to make use of DllMain to handle this sort of
initialization
in Win32 pthread_once can be simulated by using something similar to
the the following:
struct OnceInfo {
DWORD counter;
bool done;
};
static OnceInfo info = {-1,false};
void doOnce(OnceInfo& info,void (*foo)())
{
if (InterlockedIncrement(&info.counter)==0) {
foo();
info.done=true;
} else while (!info.done) Sleep(0);
}
void someFunc() { doOnce(info,foo); }