Queues an update function and returns an Awaitable that completes with the new value after the update is applied. @param updateFn a function from current value to new value @return an awaitable holding the new value
(Function<T, T> updateFn)
| 182 | * @return an awaitable holding the new value |
| 183 | */ |
| 184 | public Awaitable<T> sendAndGet(Function<T, T> updateFn) { |
| 185 | Objects.requireNonNull(updateFn, "update function must not be null"); |
| 186 | CompletableFuture<T> cf = new CompletableFuture<>(); |
| 187 | updateExecutor.execute(() -> { |
| 188 | try { |
| 189 | T newVal = applyUpdate(updateFn); |
| 190 | cf.complete(newVal); |
| 191 | } catch (Throwable t) { |
| 192 | cf.completeExceptionally(t); |
| 193 | } |
| 194 | }); |
| 195 | return GroovyPromise.of(cf); |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Shuts down the agent's update executor. No further updates will |
nothing calls this directly
no test coverage detected