# How to get information

Actors are implemented as Julia Tasks running asynchronously and are represented by a messaging Link to them or by a registered name.

You can use an actor's link (or its registered name) to get information about it:

julia> using Actors

julia> import Actors: spawn

julia> myBehavior(lk, f, args...) = send(lk, f(args...))
myBehavior (generic function with 1 method)

julia> myactor = spawn(myBehavior, me)

julia> info(myactor)
Actor    default
Behavior myBehavior
Ident    x-d-ukih-hamub

info gives you some information about your actor. The system will on each worker pid identify an actor as a Julia Task. In order make it better identifiable for a human, the task address is also given as a Proquint identifier:

julia> using Proquint

julia> quint2uint("x-d-ukih-hamub")
0x000000010d944230

0x000000010d944230

If you register an actor, you can use its registered name to get the information. Then info will show also the actor's name:

julia> register(:myname, myactor)
true

julia> info(:myname)
Actor    default
Behavior myBehavior
Ident    x-d-ukih-hamub
Name     myname

There are two ways to get the Task variable from an actor:

1. you spawn it with a taskref keyword argument or
2. you use Actors.diag.
julia> t = Ref(Actors.diag(myactor, :task))

julia> t[]
Task (runnable) @0x000000010d944230

Note: if an actor is on a worker process (pid > 1), you cannot get access to its Task. Instead you will get a string representation of it.

If an actor fails, info will return the failed Task, which shows a clickable stack-trace in the REPL:

julia> send(myactor, :boom)
(:boom,)

julia> info(myactor)
MethodError: objects of type Symbol are not callable
Stacktrace:
....

julia> typeof(ans)
Task

We can get the same information from the Ref{Task}-variable, we created earlier:

julia> t

julia> t[]
MethodError: objects of type Symbol are not callable
Stacktrace:
....

If a monitored or supervised actor has failed, you can get the failed task by using Actors.diag with the :err argument from the monitor or supervisor.

For diagnostic purposes it is possible to get access to an actor's state by using Actors.diag. See also Diagnostics.
whereisFind out whether an actor name is registered,
registeredReturn all registered actors in the system,
count_childrentell a supervisor to return a children count,
which_childrentell a supervisor to return a list of its children.