Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

receiving a message from an actor #2302

Closed
xcombelle opened this issue Oct 23, 2017 · 2 comments
Closed

receiving a message from an actor #2302

xcombelle opened this issue Oct 23, 2017 · 2 comments

Comments

@xcombelle
Copy link

xcombelle commented Oct 23, 2017

I was thinking about how one could gather the results of an actor, and keeping in sync with the flow of the caller. Create a behaviour for this purpose would be possible put would not allow the sync part.

I believe this should be useful for several conception at least for queue and future

So I came with the following new syntax. (To be bikeshedding on exact syntax
or keyword)

actor Future
  new create() =>
    None
  
  be compute() =>
    env.out.print("a possible long processing which can be interrupted")
    let result = 1+2
    #on_call execution point
    on_call result():int =>
        return result


actor Queue
  new create() =>
    None
  be enqueue(item:int) =>
    on_call dequeue():int =>
        return item


actor Main

  new create(env:Env) =>
     let f = Future.create()
     f.compute()
     #on_call calling point
     env.out.print(f.result())
     let q = Queue.create()
     q.enqueue(1)
     q.enqueue(2)
     q.enqueue(3)
     env.out.print(q.dequeue()) #1
     env.out.print(q.dequeue()) #2
     env.out.print(q.dequeue()) #3

How it would work? with one new actor output queue,

  • When a behaviour or a function reach the sync on_call calling point
    it put the return value of the on_call function in the output queue.

  • When an on_call calling point is reached: if there is nothing in the output queue, it wait up to the point the queue is filled. If there is something in the output queue, it return the first item of the output queue as the result of the on_call call

To sum up it is the symmetric operation of a behaviour of an actor, but instead of sending a message from an actor, it receiving a message from an Actor.

PS: I use to be unclear in my wording, so don't hesitate to ask for clarification.

@chalcolith
Copy link
Member

I would think you can accomplish this with promises.

@chalcolith
Copy link
Member

Probably better discussed on the mailing list. You could also create an RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants