MCPcopy Index your code
hub / github.com/apache/groovy / sendAndGet

Method sendAndGet

src/main/java/groovy/concurrent/Agent.java:184–196  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

applyUpdateMethod · 0.95
ofMethod · 0.95
completeExceptionallyMethod · 0.80
executeMethod · 0.45
completeMethod · 0.45

Tested by

no test coverage detected