MCPcopy Create free account
hub / github.com/apache/groovy / send

Method send

src/main/java/groovy/concurrent/BroadcastChannel.java:110–123  ·  view source on GitHub ↗

Sends a value to all current subscribers. @param value the value to broadcast @return an Awaitable that completes when all subscribers have accepted the value @throws ChannelClosedException if the broadcast channel is closed

(T value)

Source from the content-addressed store, hash-verified

108 * @throws ChannelClosedException if the broadcast channel is closed
109 */
110 public Awaitable<Void> send(T value) {
111 Objects.requireNonNull(value, "value must not be null");
112 if (closed) throw new ChannelClosedException("BroadcastChannel is closed");
113 CompletableFuture<?>[] futures = subscribers.stream()
114 .map(sub -> {
115 try {
116 return sub.send(value).toCompletableFuture();
117 } catch (ChannelClosedException e) {
118 return CompletableFuture.completedFuture(null);
119 }
120 })
121 .toArray(CompletableFuture[]::new);
122 return GroovyPromise.of(CompletableFuture.allOf(futures));
123 }
124
125 /**
126 * Closes this broadcast channel and all subscriber channels.

Callers

nothing calls this directly

Calls 6

ofMethod · 0.95
mapMethod · 0.65
streamMethod · 0.65
toCompletableFutureMethod · 0.65
sendMethod · 0.65
toArrayMethod · 0.45

Tested by

no test coverage detected