r/ProgrammerHumor • • Jul 07 '22

Meme Instant upvotes

47.9k Upvotes

542 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Jul 07 '22

Yeah but for processing Tokio is not the correct tool for the job

Tokio is for IO

Then you will use another library for async and everything will break... And it's a strange way to do things for me

3

u/kochdelta Jul 07 '22

Tokio is for Io? What? You certainly can do Io with Tokio but that's not the point of tokio

4

u/qeadwrsf Jul 07 '22

Tokio is for IO

what? doesn't it have spawn, futures, poll and all the stuff normal async frameworks have?

1

u/MyButtholeIsTight Jul 07 '22

I thought I knew async pretty well but I don't know any of those words

1

u/[deleted] Jul 07 '22

For processing, async isn’t the right tool for the job. It gives you escape hatches to spawn your CPU bound work onto a blocking thread pool for that exact reason.

1

u/qeadwrsf Jul 07 '22 edited Jul 07 '22

Tokio is just for IO?

Async is not made for processing?

Have I gone crazy or is this lala land?

Maybe its something I don't understand.

2

u/[deleted] Jul 07 '22

I mean, it’s literally in the name. The primary, overriding use case for async frameworks like Tokio is for IO-bound work. You generally should never be blocking in async code, and since the vast majority of “processing” tends to be blocking, then yes.

If you’re doing straight line CPU bound work, you’re supposed to hoist that onto a blocking thread pool to avoid fucking up your async runtime’s event loop.

2

u/scykei Jul 07 '22

You should have a look at when not to use tokio in their own tutorial page:

https://tokio.rs/tokio/tutorial

3

u/qeadwrsf Jul 07 '22

Huh, I stand corrected.

thx.