| 55 | |
| 56 | |
| 57 | bool Latch::await(const Duration& duration) |
| 58 | { |
| 59 | if (!triggered.load()) { |
| 60 | process::wait(pid, duration); // Explict to disambiguate. |
| 61 | // It's possible that we failed to wait because: |
| 62 | // (1) Our process has already terminated. |
| 63 | // (2) We timed out (i.e., duration was not "infinite"). |
| 64 | |
| 65 | // In the event of (1) we might need to return 'true' since a |
| 66 | // terminated process might imply that the latch has been |
| 67 | // triggered. To capture this we simply return the value of |
| 68 | // 'triggered' (which will also capture cases where we actually |
| 69 | // timed out but have since triggered, which seems like an |
| 70 | // acceptable semantics given such a "tie"). |
| 71 | return triggered.load(); |
| 72 | } |
| 73 | |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | } // namespace process { |