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

Class ActorOptions

src/main/java/groovy/concurrent/ActorOptions.java:61–240  ·  view source on GitHub ↗

Construction-time configuration for an Actor. Carries the mailbox capacity / overflow policy, the optional stash capacity / overflow policy, the executor, and the opt-in flag for Actor#currentSelf() thread-local support. Pass to the {@link Actor#reactor(java.util.function.Functio

Source from the content-addressed store, hash-verified

59 * @since 6.0.0
60 */
61public record ActorOptions(int mailboxCapacity, Overflow overflow,
62 int stashCapacity, StashOverflow stashOverflow,
63 Executor executor, boolean currentSelfEnabled) {
64
65 /**
66 * Policy applied when {@link Actor#send(Object)} is called on an actor
67 * whose bounded mailbox is full.
68 *
69 * @since 6.0.0
70 */
71 public enum Overflow {
72 /** The sending thread blocks until space is available. */
73 BLOCK,
74 /** The new message is silently dropped. */
75 DROP_NEWEST,
76 /** {@link Actor#send(Object)} throws {@link IllegalStateException}. */
77 FAIL
78 }
79
80 /**
81 * Policy applied when {@link ActorContext#stash()} is called and the
82 * actor's bounded stash is already at capacity.
83 * <p>
84 * There is no {@code BLOCK} variant: the handler running {@code stash()}
85 * is on the actor's only worker thread, so blocking it on stash capacity
86 * would deadlock.
87 *
88 * @since 6.0.0
89 */
90 public enum StashOverflow {
91 /**
92 * {@link ActorContext#stash()} throws {@link IllegalStateException}.
93 * The exception propagates out of the handler unless caught; if
94 * uncaught, the dispatch treats it as a normal handler failure
95 * (reply bound to the exception, {@code onError} fires).
96 */
97 FAIL,
98 /**
99 * The oldest stashed message is evicted to make room for the
100 * current one. If the evicted message originated from
101 * {@link Actor#sendAndGet(Object)}, its reply is bound to
102 * {@link IllegalStateException} so the caller does not wait forever.
103 */
104 DROP_OLDEST,
105 /**
106 * The current message is rejected: any {@code sendAndGet} reply
107 * is bound to {@link IllegalStateException}; any pending state
108 * change computed by the current handler is discarded; the
109 * message is <em>not</em> added to the stash and will not be
110 * replayed.
111 */
112 REJECT
113 }
114
115 /**
116 * Default options: unbounded mailbox, unbounded stash, default async
117 * executor, no thread-local current-self.
118 * <p>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected