Giter VIP home page Giter VIP logo

Comments (5)

epwalsh avatar epwalsh commented on June 26, 2024 2

@Yevgnen, great question! I'm glad you asked because it turns out it's actually not needed since flume::Sender is Sync (https://docs.rs/flume/latest/flume/struct.Sender.html#impl-Sync). #22 will remove the Mutex.

from batched-fn.

epwalsh avatar epwalsh commented on June 26, 2024

Hi @liebkne! See https://docs.rs/batched-fn/latest/batched_fn/#implementation-details, in particular:

When the batched_fn macro is invoked it spawns a new thread where the handler will be ran. Within that thread, every object specified in the context is initialized and then passed by reference to the handler each time it is run.

All three arguments (handler, config, and context) are required, and yes, the code inside context is only run once for initialization.

I hope that answers your question! I haven't used actix recently, but if you do get an example working I'd be happy to share it in this repo.

from batched-fn.

liebkne avatar liebkne commented on June 26, 2024

@epwalsh

That's great help! Thank you very much! Following you hints, I spent some time to understand the macro and I think I've understood 90% of it. 😂

I will try to make a working example and once I did I will make a PR.

from batched-fn.

epwalsh avatar epwalsh commented on June 26, 2024

Great! Looking forward to it 🙂

from batched-fn.

Yevgnen avatar Yevgnen commented on June 26, 2024

I'm also pretty new to Rust and async things and found a tutorial from tokio-channel. After I read the source code I found the pattern (using channels) of the library is similar.

@epwalsh May I ask a question? Why Mutex is needed in BatchedFn?

from batched-fn.

Related Issues (6)

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.