Git Product home page Git Product logo

Comments (2)

Boscop avatar Boscop commented on May 29, 2024 1

Thanks for the quick reply.

By background do you mean in other threads? I think it should not be done by default. My current use cases are all written by sharing a RefCell without Mutex and I think the single-threaded model should stay the default because it's usually sufficient and the simplest to manage (and for backwards compatibility with code using this crate where the job closures aren't Send + 'static)..
E.g. in my cases, it has to stay that way that only one job is running at a time and they all run sequentially..

When you introduce multi-threading, it would force all closures to be Send + 'static, even for use cases that will be configured to run sequentially/single-threaded, requiring Arc<Mutex<SharedData>> :/
Maybe it would make sense to introduce a second ParallelJobScheduler which requires the closures to be Send + 'static but the normal one doesn't have to impose those constraints on the closures..

The debouncing wouldn't be necessary for multi-threading because jobs never have to be delayed by other jobs (but it could be configurable if they should be re-entrant or run sequentially with other instances of the same job).

And the need to run at most 1 job per tick() call also doesn't apply to the multi-threaded version because there wouldn't have to be a tick() call to advance the jobs..

So I think the multi-threading version of the JobScheduler should be thought about separately from the needs / config options that only apply to the single threaded version.

E.g. I would add the config options for "run at most 1 job per tick() call" and "run at most 1 instance of a delayed job, before starting the waiting period again" to the single-threaded JobScheduler first, and then afterwards think about designing a multi-threaded version :)

from job_scheduler.

lholden avatar lholden commented on May 29, 2024

Funny, I have use cases that have the inverse requirement. Occasionally a job will get backed up and I want the system to catch up.

It seems entirely reasonable and expected to be able to debounce requests though.

An interesting quirk in regards to debouncing though.. another user requested that jobs be able to run in the background. Backgrounded + debounce would require synchronizing the status and such.

Seems like when starting up the scheduler you should be able to configure features such as backgrounding and debouncing.

I'll take a look at implementing this in the near future. Likely this weekend or maybe while at RustConf.

from job_scheduler.

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.