Created
April 2, 2012 23:45
-
-
Save davisp/2288078 to your computer and use it in GitHub Desktop.
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
| +wait_loop(Parent, Timeout, State) -> | |
| % State transitions | |
| % unset -> (updated | timeout | waiting) | |
| % updated -> (updated | unset) | |
| % timeout -> (unset | updated) | |
| % waiting -> unset | |
| receive | |
| db_updated when State == waiting -> | |
| Parent ! updated, | |
| wait_loop(Parent, Timeout, unset); | |
| db_updated when State == unset orelse State == updated -> | |
| wait_loop(Parent, Timeout, updated); | |
| get_state when State == unset -> | |
| wait_loop(Parent, Timeout, waiting); | |
| get_state -> | |
| Parent ! State, | |
| wait_loop(Parent, Timeout, unset); | |
| done -> | |
| ok | |
| after Timeout -> | |
| case State of | |
| waiting -> | |
| Parent ! timeout; | |
| unset -> | |
| wait_loop(Parent, Timeout, timeout) | |
| end | |
| end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Agree about the timeout (typo there), not sure I agree about the drain but I'll defer to your judgement there. Let me push a PR so we can get more eyeballs on it
cloudant/fabric@cca4750