Giter Site home page Giter Site logo

Comments (9)

Restioson avatar Restioson commented on May 16, 2024

This does make sense to me, I think. I really like how this simplifies control flow and general usage - less ways to do the same thing. You can emulate preventing an actor from shutdown from Actor::stopping by adding a ShutdownMaybe message which then checks if the actor should be shut down, and calls Context::stop if required.

from xtra.

Restioson avatar Restioson commented on May 16, 2024

This would supercede and close #58, right?

from xtra.

thomaseizinger avatar thomaseizinger commented on May 16, 2024

This would supercede and close #58, right?

Yes.

from xtra.

thomaseizinger avatar thomaseizinger commented on May 16, 2024

This does make sense to me, I think. I really like how this simplifies control flow and general usage - less ways to do the same thing. You can emulate preventing an actor from shutdown from Actor::stopping by adding a ShutdownMaybe message which then checks if the actor should be shut down, and calls Context::stop if required.

Yep, I had a similar thought. I think moving more of this functionality into messages is a good thing.

I've also been contemplating the idea of making the started lifecycle hook a message but I am not fully sure about that yet :)

from xtra.

Restioson avatar Restioson commented on May 16, 2024

How would replacing started work? Would each address of the actor be made to send a start message?

from xtra.

thomaseizinger avatar thomaseizinger commented on May 16, 2024

I was thinking of something like this (assuming #62):

impl Context {
	pub async fn run<A>(mut self, actor: A) -> A::Stop where A: Actor + Handler<Started, ()> {
		self.address.send(Started).await;
	}
}

But I just realized that that doesn't work because we obviously can't receive messages until we are in the actual loop within the context.

from xtra.

thomaseizinger avatar thomaseizinger commented on May 16, 2024

This does make sense to me, I think. I really like how this simplifies control flow and general usage - less ways to do the same thing. You can emulate preventing an actor from shutdown from Actor::stopping by adding a ShutdownMaybe message which then checks if the actor should be shut down, and calls Context::stop if required.

Cool. If you are on-board with that, I will have a go at removing the function and all the code associated with KeepRunning etc.

from xtra.

Restioson avatar Restioson commented on May 16, 2024

Sure, and thanks! 👍

from xtra.

Restioson avatar Restioson commented on May 16, 2024

Solved by #82 . Note that KeepRunning was kept for attach_stream but when this is moved to an extension crate it will go there too.

from xtra.

Related Issues (20)

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.