Using libraries depending on different async runtimes in one application
Suppose there are two async libraries which I want to use together in one program, but they are built depending on different runtimes (tokio and async-std). Mixing two runtimes in one program does not seem right to me, and I believe that given that these libraries do have their particular dependency, they might break if I use them against a different runtime. It is also not really clear how should I choose a runtime in this case.
Curiously, I couldn't find any discussions or articles which explain what to do in such a situation. All of the information I was able to find explain how to use either runtime, or maybe how to choose between runtimes when there are no prior dependencies. But I'm really curious what to do if I end up depending on both runtimes transitively.
20 comments · 98% upvoted · other discussions
Someone who's actually tried this correct me please. My current understanding is:
CryZe92 14 points · Dec 2019
Tokio requires the reactor to run. You can use any future with any executor (that‘s the whole point of the waker system).
The problem with async-std is that it always spawns its own reactor in the background, even if you already have an existing tokio reactor running, causing more overhead in the end, with no option to configure it.
rodyamirov 3 points · Dec 2019
So does this mean the utility functions in tokio can create futures which could be given to a non-tokio executor? My understanding was this is not the case, that typically things that create futures tend to be stuck to a reactor regardless, not in theory but in practice, and I'm not sure why this is the case.
Not an expert, genuinely trying to learn.
killercup 5 points · Dec 2019
Sorry just a dumb user who has never looked into this deeper so async-std "just working" is fine with me :)
Is there any guide on how to combine these libraries in the most efficient/least annoying way btw? I (and probably a lot of other folks) would really appreciate that.
[deleted] 2 points · Dec 2019
[deleted]
[deleted] 5 points · Dec 2019
[deleted]
[deleted] 1 points · Dec 2019
Why would anyone try to spread FUD about this?
[deleted] 1 points · Dec 2019
[deleted]
[deleted] 0 points · Dec 2019
Can you elaborate? Sounds like you are claiming that tokio users/devs are a different species than async-std users/devs.
cerebellum42 3 points · Dec 2019
They said Intra not inter, so same not different
[deleted] 1 points · Dec 2019
So I have still no idea why anyone would want to spread FUD about the different async libraries. As I see it, the more options we have, the better :/
load 0 more replies →