gamazeps / robots Goto Github PK
View Code? Open in Web Editor NEWActor system for Rust
License: MIT License
Actor system for Rust
License: MIT License
Would it be possible to implement typed actors? I made a small example https://gist.github.com/Pireax/9e65b9188a188e2a35051c2708b837ed, this ignores the whole mailbox, threading, etc so it isn't an exact match but is it possible to implement such a thing? It would allow for safer code.
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?
I have tried with:
robots = "0.3.0"
and
robots = { git = "https://github.com/gamazeps/RobotS.git" }
but I get: no matching package named robots
(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.
Do you have any examples somewhere?
This lib exited my whole server ! :@ sad angry tears
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
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.