News for hackers. Stuff that matters.
Re:Tokio 1.0 – async runtime for Rust by programmarchy on Wednesday December 23, 2020 @02:24PM (#25521100)
Would it be fair to compare this to Apple's Grand Central Dispatch a.k.a. libdispatch?
Re:Tokio 1.0 – async runtime for Rust by dangerbird2 on Wednesday December 23, 2020 @02:34PM (#25521226)
It's similar. libdispatch is primarily a task queue to simplify and optimize multithreaded workloads in objc/swift. Tokio uses a similar task queue pattern for scheduling cpu-bound or blocking io, but the main feature is an non-blocking/asynchronous IO runtime. Overall, it's more similar to libuv (the async io library that powers node.js), but with built-in support for Rust's async/await syntax
Re:Tokio 1.0 – async runtime for Rust by baby on Wednesday December 23, 2020 @04:34PM (#25522487)
You mean io-bound
Re:Tokio 1.0 – async runtime for Rust by Matthias247 on Wednesday December 23, 2020 @06:25PM (#25523471)
Yes in some regards. Both offer eventloops (in GCD: dispatch queues), which run small chunks of code which belongs to independent tasks on the same thread.

However there are some differences:

- Tokio is focussed on running async/await based code, whereas libdispatch currently mostly targets running callbacks/continuations. This might change once Swift offers async/await support, which for sure could run on top of GCD queues.

- GCD queues provide a lot more fine-grained control. users can exactly specify on which queue to run some code on. And tasks can jump between code. There might also be a dedicated main thread (UI) queue. Tokio just spins up a single queue which runs all code, which might be empowered by a multithreaded executor. This makes it less usable for UI.

Re:Tokio 1.0 – async runtime for Rust by pas on Wednesday December 23, 2020 @02:29PM (#25521168)
Yes, but it's strictly userspace. It's more like the concurrency primitives in the JVM. (Eg. work-stealing threadpool, timers, various abstractions over OS/kernel lower level async stuff.)
Re:Tokio 1.0 – async runtime for Rust by MuffinFlavored on Wednesday December 23, 2020 @02:29PM (#25521157)
To me it's kind of like the event loop of node.js (which I believe comes from libuv)?
Re:Tokio 1.0 – async runtime for Rust by lucacasonato on Wednesday December 23, 2020 @02:32PM (#25521197)
Yes, Deno uses it as its internal event loop for JS code.
Re:Tokio 1.0 – async runtime for Rust by steveklabnik on Wednesday December 23, 2020 @02:39PM (#25521278)
Fun party fact: long ago, Rust had libuv built in too.
Re:Tokio 1.0 – async runtime for Rust by shepmaster on Wednesday December 23, 2020 @02:47PM (#25521372)
... for not-so-fun parties. ;-)
Re:Tokio 1.0 – async runtime for Rust by p5a0u9l on Wednesday December 23, 2020 @03:56PM (#25522129)
why’d they move past it? does libuv not fit well in rust?
Re:Tokio 1.0 – async runtime for Rust by creata on Wednesday December 23, 2020 @04:05PM (#25522226)
Rust used to have a lot of stuff built into the language, including garbage collection![0] I think that a long time ago they chose to move stuff out into libraries so that Rust could be a serious competitor to C++.

https://pcwalton.github.io/2013/06/02/removing-garbage-colle...

Re:Tokio 1.0 – async runtime for Rust by steveklabnik on Wednesday December 23, 2020 @03:59PM (#25522158)
Back then, Rust had a built-in runtime. It was removed, and libuv with it.