Skip to content

Instantly share code, notes, and snippets.

@afeinberg
Created November 11, 2011 01:10
Show Gist options
  • Save afeinberg/1356822 to your computer and use it in GitHub Desktop.
Save afeinberg/1356822 to your computer and use it in GitHub Desktop.
void x() {
SomeClass blah;
asyncthread(y(blah));
}
// Note if you pass shit by reference, it should be a const reference. Otherwise just use a pointer
void y(const SomeClass &blah) {
Blah blah_copy(blah); // <-- assuming the constructor does not do a shallow copy
}
// This is how I'd design it
void x() {
shared_ptr<SomeClass> blah(new SomeClass);
asyncthread(y(blah)));
}
void y(const shared_ptr<SomeClass> &blah) {
doShit(*blah);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment