Returns true if this Once instance has already transitioned to a 'done' state (i.e., the action you wanted to perform "once" has been completed). Note that this BLOCKS until Once::done has been called.
| 34 | // been completed). Note that this BLOCKS until Once::done has been |
| 35 | // called. |
| 36 | bool once() |
| 37 | { |
| 38 | bool result = false; |
| 39 | |
| 40 | synchronized (mutex) { |
| 41 | if (started) { |
| 42 | while (!finished) { |
| 43 | synchronized_wait(&cond, &mutex); |
| 44 | } |
| 45 | result = true; |
| 46 | } else { |
| 47 | started = true; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return result; |
| 52 | } |
| 53 | |
| 54 | // Transitions this Once instance to a 'done' state. |
| 55 | void done() |
no outgoing calls
no test coverage detected