Coder Social home page Coder Social logo

parking's People

Contributors

dependabot[bot] avatar dfirebird avatar fogti avatar notgull avatar taiki-e 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

Watchers

 avatar  avatar  avatar  avatar  avatar

parking's Issues

Add a zero-allocation way to get a Waker from an Unparker

Unparker is an Arc<Inner>. If Inner implements std::task::Wake, that Arc<Inner> can be converted into a Waker without any additional allocations. This would be useful for the implementation of futures_lite::future::block_on, whose Waker implementation just calls Unparker::unpark.

Specify the advantages that this crate has over the standard library thread::park()

It is unclear from looking through the docs and the readme of this crate what advantages it has over using the standard library std::thread::park() and std::thread::Thread::unpark() functions. A cursory glance over the codebase seems to indicate that it uses the same code that the generic thread-parking function uses, which means that it allocates memory for something threads already have built-in. The main advantage from what I can glean is that this algorithm defeats spurious wakeups, which the standard library doesn't guarantee. However, all three implementations already have guards against spurious wakeups.

Support passing values through the Mutex inside the parker

The caller of Unparker::unpark briefly has the lock on the Mutex before notifying the condvar. Would it be feasible to pass a Send value through the Mutex to the unparked thread for it to consume? Perhaps, say, a async_task runnable? If the threads already unparked or never was to begin with,unpark can just return back an error containing the value.

Add support for WASM targets

In WebAssembly targets, blocking is unimplemented in the standard library except for target_feature = "atomics". Therefore blocking cannot happen until that feature is used. But, we can compile conditionally for that feature.

On web browsers, there is an Atomics API that can be used to block in Web Workers, but not on the main thread. So we could conditionally select that on web (like getrandom does), and then try to get that API. Then, if we're in a web worker, block, and if we're in the main thread, panic.

We could even have a try_park() method that allows users to handle the case of if they cannot actually park, because they're on the main thread. This would allow users to handle the case of not parking.

It would be nice to implement this in parking, that way it can be bubbled up to other primitives in smol.

See this comment for more info.

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.