Closed pbayer closed 3 years ago
Actors should support function objects instead of only Function. See issue 15 to YAActL.
Actors
should support actor tasks as in Elixir, see also issue 16 to YAActL.
When reading about the GenServer in Erlang/Elixir I was thinking about how to implement that with Actors. Also @felipecarregosa mentioned its usefulness on Discourse.
I realize that executing a callback function on Call
, Cast
and so on is totally different from what the actor does with onmessage
currently. Therefore I will right away:
mode
field into _ACT
,update!
and query!
to work with it,mode=:default
keyword into spawn
and onmessage(A::_ACT, mode, msg)
Then a GenServer
module can implement Actors.onmessage(A::_ACT, ::Val{:GenServer}, msg::Call)
and so on. (Likewise can do other modules.)
A user then should be able to do
using GenServer
...
servy = spawn(MyModule, something)
call!(servy, 10) # this should execute handle_call(something, 10) in MyModule
or similarly ... We have yet to figure out how this may be implemented in detail. But the above changes enable it in principle.
Note: Thus the interface idea of @tisztamo keeps generating new ideas and solutions.
Actually there is not very much to figure out. The callback stuff can be done with modules. For example:
module myA
f() = 1
end
module myB
f() = 2
end
dof(m::Module) = m.f()
then
julia> dof(myA)
1
julia> dof(myB)
2
This means a GenServer
module can on spawn(MyModule, something)
assign MyModule
to the _ACT.usr
variable and execute MyModule.init(something)
and so on. This can be tried soon if I register v0.1.2.
@felipecarregosa would you like to do it?
@JuliaRegistrator register
Registration pull request created: JuliaRegistries/General/24950
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:
git tag -a v0.1.2 -m "<description of version>" 4f65c773cc9f5d040114bb642f1a0e328afd4130
git push origin v0.1.2
v0.1.2 is available from the Julia registry
Provide Erlang/Elixir-like API functions (see also YAActL API):
call!
: call a behavior and deliver the result,cast!
: cast a message to a behavior,exec!
: execute an arbitrary function,query!
: query the actor state,update!
: update the actor state,init!
: set and execute a startup function,term!
: set a termination function,exit!
: tell an actor to exit,async
: start an actor task,await
: get the result from an actor task,mode
, see comment below,