Git Product home page Git Product logo

async-task's Introduction

async-task

A task abstraction for building executors.

Installation

With cargo add installed run:

$ cargo add async-task

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

async-task's People

Contributors

johntitor avatar laizy avatar skade avatar taiki-e avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

async-task's Issues

Question: Is running the task from schedule OK?

Hello

When browsing code around, I've came to wonder about one thing. What would go wrong, if I created a trivial „recursive“ executor by running the task directly inside the schedule closure? Eg:

let (task, handle) = async_task::spawn(future, Task::run, ());
task.run();

So far, this has crossed my mind:

  • It'll probably make it run in whatever thread wakes the future (so the thread that polls timers or epoll or whatever), which might not be happy about the added latencies.
  • Can the task get called recursively somehow?
  • If so, doesn't that create two mut references to the future?

Or, are there any other problems or restrictions what the schedule closure can do?

Provide a non-Send bound spawn method and Task implementation.

Hi. I'm in the process of writing safe rust bindings for writing Weechat
plugins. Since the Weechat plugin API is inherently asynchronous albeit callback based I had the idea that it would be nice to be able to run rust futures inside of Weechat.

I used async-task to implement an executor that runs on the Weechat event loop rather easily, thanks for the awesome project.

Now to my problem, I have a bunch of Weechat objects that should only be used on the Weechat thread. Since Weechat is in no way thread safe all interaction with Weechat (e.g. printing messages in Weechat) needs to happen inside the Weechat thread.

Since our executor does run on the Weechat thread, futures that run on it should be able to use Weechat objects, but as Weechat isn't thread safe none of them should be marked as Send.

What I would need to achieve this with async-task is a Task struct and a
spawn() method that are not Send bound. I saw this issue on the async-std tracker, and it seems that I'm not the only one with such a requirement.

I would assume that any C project that runs on some event loop might want to implement an event-loop local executor as well, provided that they are writing rust bindings.

For reference, my prototype executor implementation can be found
here. I'm using a forked version of async-task where I just removed the Send bounds.

Memory holding schedule function might be freed during its invocation

Currently waking the waker by value hands over the ownership of the task to the
schedule without retaining any refcount on its own. Once the scheduling
function hands over the ownership of task further there is no guarantee that
memory that holds scheduling function will remain valid.

For example (drop(task) is used to avoid irrelevant complexity):

fn main() {
    let s = "1234".to_owned();

    let (task, _) = async_task::spawn(
        async {},
        move |task| {
            println!("{:?}", s);
            drop(task);
            println!("{:?}", s);
        },
        (),
    );
    task.schedule();
}

2.0 published, but no changes in this repo

It looks like version 2.0 has been pushed to crates.io, but it doesn't seem like anything has changed in this async-task repo in a few months. Is this just local development taking place or a different primary repo?

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.