bcndanos / asynchronous Goto Github PK
View Code? Open in Web Editor NEWAsynchronous promises in rust using threads
License: MIT License
Asynchronous promises in rust using threads
License: MIT License
It makes sense to have the promise chain begin in a new thread from Promise::new()
, however beyond that the continuations themselves shouldn't be in separate threads of their own. They should all run on the originating thread where the Promise was created.
Apart from the thread locality of the continuations, the idea of creating a separate thread for each continuation is expensive. These aren't green threads, and so I'm afraid this Promise implementation will not scale well when put to the test.
Right now the promise closure must return only a Result<T, E> type, which makes it clunky to chain promise handlers together. A coherent promise implementation allows one to return a value or another promise, and when a continuation is done on the outer promise, it is continuing on the inner promise that was returned.
I suggest creating an enum type for the return type of all the methods, that can be either another Promise<T, E> type or be a Result<T, E> type. I have no idea if Rust's type system will get in the way here, or type inference will fail miserably...but this is the first thing that comes to my mind when thinking about solving the problem.
Hi,
Looks like a cool library, only have one small feature request: a non blocking try_sync that returns a value if there is one and None otherwise.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.