Giter Site home page Giter Site logo

Comments (4)

lulf avatar lulf commented on September 13, 2024 1

I'm going to attempt to improve the experience of writing and running actors as follows:

  1. Introduce a spawn_actor! macro to simplify creation and mounting of the actor context + actor:
let address = spawn_actor!(spawner, BUTTON_A, Button::new(board.btn_a));
  1. Introduce a actor proc macro to simplify the Actor impl:
#[actor]
impl Actor for MyActor {
    type Message<'m> = MyMessage;
    async fn on_mount<M>(&mut self, address: Address<Self>, inbox: &mut M)
        where M: Inbox<Self>
    {
        loop {
            if let Some(m) = inbox.next().await {
                // ... handle message
            }
        }
    }
}

The purpose of this macro is not to remove all the boilerplate, but rather prepare the actor implementations to require minimal modifications when async traits are fully available in Rust, so that just removing the #[actor] macro (and making the macro a dummy) will allow the code to keep working.

from drogue-device.

ctron avatar ctron commented on September 13, 2024

What I guess would help is:

  • Add some documentation on the actor model of Drogue Device
    • What is an actor
    • What is the lifecycle? Init, Inbox, ...
    • When to use an actor vs when not to
  • A basic tutorial, which builds (step by step) a simple device (like a blinking LED with a push-button that changes its behavior). Maybe pointing to a dedicated GitHub repository, which contains the full code (and only that). Ready to check out, build, and flash on a device we choose (like the microbit).

from drogue-device.

ctron avatar ctron commented on September 13, 2024

Ok, after re-checking the docs. I think it already is there.

from drogue-device.

lulf avatar lulf commented on September 13, 2024

Improvements:

  • Added cargo xtask clone in #244
  • Added docs for BSP in #245

Will take a stab at improving the code docs.

from drogue-device.

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.