4 ms·
Would it be fair to compare this to Apple's Grand Central Dispatch a.k.a. libdispatch?
by programmarchy 6y ago
Would it be fair to compare this to Apple's Grand Central Dispatch a.k.a. libdispatch?
- MuffinFlavored 6y agoTo me it's kind of like the event loop of node.js (which I believe comes from libuv)?
- lucacasonato 6y agoYes, Deno uses it as its internal event loop for JS code.
- steveklabnik 6y agoFun party fact: long ago, Rust had libuv built in too.
- shepmaster 6y ago... for not-so-fun parties. ;-)
- p5a0u9l 6y agowhy’d they move past it? does libuv not fit well in rust?
- steveklabnik 6y agoBack then, Rust had a built-in runtime. It was removed, and libuv with it.
- creata 6y agoRust 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-collection-from-the-rust-language.html https://pcwalton.github.io/2013/06/02/removing-garbage-colle...
- pas 6y agoYes, 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.)
- dangerbird2 6y agoIt'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
- baby 6y agoYou mean io-bound
- Matthias247 6y agoYes 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.