Created
November 9, 2012 20:15
-
-
Save bstrie/4047954 to your computer and use it in GitHub Desktop.
Drop trait
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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