Skip to content

Instantly share code, notes, and snippets.

@bstrie
Created November 9, 2012 20:15
Show Gist options
  • Select an option

  • Save bstrie/4047954 to your computer and use it in GitHub Desktop.

Select an option

Save bstrie/4047954 to your computer and use it in GitHub Desktop.
Drop trait
struct PoisonOnFail {
failed: &mut bool,
}
impl PoisonOnFail : Drop {
fn finalize() {
/* assert !*self.failed; -- might be false in case of cond.wait() */
if task::failing() { *self.failed = true; }
}
}
struct PoisonOnFail {
failed: &mut bool,
drop {
/* assert !*self.failed; -- might be false in case of cond.wait() */
if task::failing() { *self.failed = true; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment