JuliaActors / Actors.jl

Concurrent computing in Julia based on the Actor Model
MIT License
106 stars 11 forks source link

Actor API #8

Closed pbayer closed 3 years ago

pbayer commented 3 years ago

Provide Erlang/Elixir-like API functions (see also YAActL API):

pbayer commented 3 years ago

Actors should support function objects instead of only Function. See issue 15 to YAActL.

pbayer commented 3 years ago

Actors should support actor tasks as in Elixir, see also issue 16 to YAActL.

pbayer commented 3 years ago

Introduce Actor Mode

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:

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.

pbayer commented 3 years ago

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?

pbayer commented 3 years ago

Actors v0.1.2 with improved usability

@JuliaRegistrator register

JuliaRegistrator commented 3 years ago

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
pbayer commented 3 years ago

v0.1.2 is available from the Julia registry