4 ms·
You can't evaluate a future in normal rust as there's no default executor, you need to pull in some library to even make blocking calls to async functions. IMO
by moth-fuzz 3y ago
You can't evaluate a future in normal rust as there's no default executor, you need to pull in some library to even make blocking calls to async functions.
IMO, this is even worse than function coloring.
- zanellato19 3y agoYou can also make your own executor. That's exactly how it was intended.
- weinzierl 3y agoIt's a bit strange indeed. On the other hand you can't allocate either if you don't have an allocator. The difference is just that the allocator is opt-out while the reactor and executor are opt-in with no formal default.
- jarjoura 3y agoIt's the same in C++. The compiler and language design came first and then the library (aka executor) part comes next. Rust has basically 2 executor libraries, tokio and async-std. It seems to me like tokio is solidifying as the executor of choice and it's only a matter of time before that design is baked into the std library.
- menaerus 3y agoIn C++ there is a default executor that is part of the standard library and has been so since C++11, e.g. no external library is needed - std::async. std::async is mostly "good enough" for ordinary cases where you only want to fire-and-forget and have no control over the underlying dispatching and scheduling algorithms. If you want something tweaked towards your use-case, and hence actual high-performance executor library, std::async is not gonna cut it. And that's where the "C++ executors" proposal come in.
- BatmanAoD 3y agoThat's...not precisely true. The C++ standard doesn't specify how std::async works, and for a while GCC just ran the operation sequentially, and later both GCC and Clang launched new OS threads by default. https://stackoverflow.com/q/10059239/1858225 https://stackoverflow.com/q/10059239/1858225