Skip to content

Instantly share code, notes, and snippets.

@rukletsov
Created February 1, 2017 02:43
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 rukletsov/929d86d0dc6e3ecbb50f10667c4dfef2 to your computer and use it in GitHub Desktop.
Save rukletsov/929d86d0dc6e3ecbb50f10667c4dfef2 to your computer and use it in GitHub Desktop.
bool wait(const UPID& pid, const Duration& duration)
{
process::initialize();
if (!pid) {
return false;
}
// This could result in a deadlock if some code decides to wait on a
// process that has invoked that code!
if (__process__ != nullptr && __process__->self() == pid) {
std::cerr << "\n**** DEADLOCK DETECTED! ****\nYou are waiting on process "
<< pid << " that it is currently executing." << std::endl;
((Promise<Nothing>*)0xDEAD)->future();
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment