Completes this operation successfully. The stopwatch given during construction is used to measure the elapsed time. Registered callbacks are invoked and provided the measured elapsed time. @return true if the operation is marked as complete; false if it was already complete
()
| 122 | * @return true if the operation is marked as complete; false if it was already complete |
| 123 | */ |
| 124 | public boolean complete() { |
| 125 | Map<ClientTransport.PingCallback, Executor> callbacks; |
| 126 | long roundTripTimeNanos; |
| 127 | synchronized (this) { |
| 128 | if (completed) { |
| 129 | return false; |
| 130 | } |
| 131 | completed = true; |
| 132 | roundTripTimeNanos = this.roundTripTimeNanos = stopwatch.elapsed(TimeUnit.NANOSECONDS); |
| 133 | callbacks = this.callbacks; |
| 134 | this.callbacks = null; |
| 135 | } |
| 136 | for (Map.Entry<ClientTransport.PingCallback, Executor> entry : callbacks.entrySet()) { |
| 137 | doExecute(entry.getValue(), asRunnable(entry.getKey(), roundTripTimeNanos)); |
| 138 | } |
| 139 | return true; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Completes this operation exceptionally. Registered callbacks are invoked and provided the |