public final class DefaultActor<T>
extends Object
implements Actor
Default implementation of Actor.
Each actor runs on a dedicated worker thread (virtual on JDK 21+) and dispatches messages sequentially from a FIFO mailbox, guaranteeing thread-safe state access without locks. The mailbox is a LinkedBlockingDeque so that ActorContext.unstashAll can re-inject deferred messages at the head of the queue; a Semaphore gates send-side capacity for bounded mailboxes (the deque itself is internally unbounded). A message's permit is released as soon as the worker takes it from the deque — so the bound applies to the queue, not to messages currently being processed or held in the stash buffer; the stash buffer itself is unbounded.
T - the message type| Type Params | Return Type | Name and description |
|---|---|---|
|
public static Actor<?> |
currentlyExecuting()Implementation hook for Actor.currentSelf. |
|
public boolean |
isActive() |
|
public boolean |
isTerminated() |
|
public Actor<T> |
onError(BiConsumer<Throwable, ? super T> handler) |
|
public Actor<T> |
onError(TriConsumer<ActorContext<T>, Throwable, ? super T> handler) |
<T, R> |
public static Actor<T> |
reactor(Function<T, R> handler, ActorOptions options) |
<T, R> |
public static Actor<T> |
reactor(ReactorHandler<T, R> handler, ActorOptions options) |
|
public void |
send(T message) |
<R> |
public Awaitable<R> |
sendAndGet(T message) |
<T, S> |
public static Actor<T> |
stateful(S initialState, BiFunction<S, T, S> handler, ActorOptions options) |
<T, S> |
public static Actor<T> |
stateful(S initialState, StatefulHandler<S, T> handler, ActorOptions options) |
|
public void |
stop() |
|
public String |
toString() |
Implementation hook for Actor.currentSelf.