-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<U> Uask(ThrowingFunction<T, U> f) Send an invocation to the actor and await for the result.static <T> ActorRef<T> The same ascreate(Scope, Object, Consumer)but with empty close action.static <T> ActorRef<T> Creates a new actor ref, that is a fork in the current concurrency scope, which protects a mutable resource (`logic`) and executes invocations on it serially, one after another.voidtell(ThrowingConsumer<T> f) Send an invocation to the actor that should be processed in the background (fire-and-forget).
-
Constructor Details
-
ActorRef
-
-
Method Details
-
ask
Send an invocation to the actor and await for the result.The `f` function should be an invocation of a method on `T` and should not directly or indirectly return the `T` value, as this might expose the actor's internal mutable state to other threads.
Any non-fatal exceptions thrown by `f` will be propagated to the caller and the actor will continue processing other invocations. Fatal exceptions will be propagated to the actor's enclosing scope, and the actor will close.
- Throws:
Exception
-
tell
Send an invocation to the actor that should be processed in the background (fire-and-forget). Might block until there's enough space in the actor's mailbox (incoming channel).Any exceptions thrown by `f` will be propagated to the actor's enclosing scope, and the actor will close.
- Throws:
InterruptedException
-
create
The same ascreate(Scope, Object, Consumer)but with empty close action. -
create
Creates a new actor ref, that is a fork in the current concurrency scope, which protects a mutable resource (`logic`) and executes invocations on it serially, one after another. It is guaranteed that `logic` will be accessed by at most one thread at a time. The methods of `logic: T` define the actor's interface (the messages that can be "sent to the actor").Invocations can be scheduled using the returned `ActorRef`. When an invocation is an `ActorRef.ask`, any non-fatal exceptions are propagated to the caller, and the actor continues. Fatal exceptions, or exceptions that occur during `ActorRef.tell` invocations, cause the actor's channel to be closed with an error, and are propagated to the enclosing scope.
The actor's mailbox (incoming channel) will have a capacity of
Channel.DEFAULT_BUFFER_SIZE.
-