Giter Club home page Giter Club logo

robots's Issues

Actors mutable state

E. g. I want to implement a simple actor that increments a counter each time it recieves a message:

struct Dummy {
    counter: u32,
}

impl Dummy {
    fn new(_: ()) -> Dummy {
        Dummy { counter: 0 }
    }
}

impl Actor for Dummy {
    fn receive(&self, message: Box<Any>, context: ActorCell) {
        self.counter += 1;
        println!("counter: {}", self.counter);
    }
}

Of course, it doesn't work. Shouldn't Actor::recieve method take a mutable reference insteade an immutable one? Or how can I implement mutable actor state?

Use queues for actors

(apologies if I misread the code)

I'm looking into the CanReceive trait, and it looks like the work is being dropped directly against the actor instead of against a work-stealing queue (like Akka does). The threads would then consume the messages from the work-stealing queues directly (for throughput, it may be a good idea to consume all items in one actor's queue then jump to the next actor, but fairness would suffer massively).

This may be contributing to the fact that sending a message on the benches is taking 4ms on my core i7 OSX laptop (which is awful).

There is a work-stealing-usable deque on servo's util package, but it would bring a ton of stuff. I would just copy the file over, but the license is Apache and RobotS' is MIT, so I don't know how that plays out.

Examples

Do you have any examples somewhere?

EventStream

Do you have any plans to implement something like Akka EventStreams?
In Scala it's looks like this:

val acts = ActorSystem()
val stream = acts.eventStream

val cblog = acts.actorOf(Props(new CallbackLogger(logger)))
stream.subscribe(cblog, classOf[CallbackMsg])

...

stream.publish(x)

cblog will receive all published CallbackMsg's

Serializing ActorRef?

Hi,
Are you planning to make ActorRef serializable when/if you create networking support?

This has been one of the most problematic things for us when creating Akka.NET (port of Akka to .NET).
Polymorphic serialization is hard and depending on serializer and platform not always possible.
(LocalActorRef, DeadLetterActorRef, RemoteActorRef, RouterActorRef etc etc)

In my other actor project https://github.com/rogeralsing/gam, I ditched the ActorRef concept and used a more Erlang like PID which is a simple value that instead of using polymorphism, resolves the underlying actor.
This way, the actor pid can easily be passed across the wire using e.g. protobuf as the serializer.

Just wanted to give a heads up on that one.
Another benefit of the above approach would be the possibility of cross platform Go <-> Rust remoting, hint hint

If you are still going down the ActorRef route, are there some interesting ways that Rust can deal with the above?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.