Skip to content

Instantly share code, notes, and snippets.

@cjameshuff
Created October 17, 2013 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjameshuff/7032684 to your computer and use it in GitHub Desktop.
Save cjameshuff/7032684 to your computer and use it in GitHub Desktop.
static Foo * foo = nullptr;
static Mutex fooLock;
Foo * GetFoo()
{
if(!foo)
{
fooLock.Lock();
if(!foo)
foo = new Foo;
fooLock.Unlock();
}
return foo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment