book-exploring-async-basics icon indicating copy to clipboard operation
book-exploring-async-basics copied to clipboard

[Translation] 8_9_infrastructure.md

Open Jaxx4Fun opened this issue 5 years ago • 3 comments

Even though we use several threads, we use a regular usize here

What does the word regular here mean? Can I regard it as simple?

We do the latter since that's the only thing that makes sense for our use case.

It needs to be 'Send since we're sending this task to another thread.

I am wondering why there is a ' in front of the word Send?

Jaxx4Fun avatar Aug 16 '20 02:08 Jaxx4Fun

What does the word regular here mean? Can I regard it as simple?

By regular I mean not an AtomicUsize just the normal usize. I guess, if you need to use another word "normal" is more correct but you can use "simple" as well if you want to. Neither is incorrect I would say.

I am wondering why there is a ' in front of the word Send?

It's a spelling mistake. I probably hit the wrong key trying to make a ` It shouldn't be there.

cfsamson avatar Aug 18 '20 09:08 cfsamson

one more question about the comment in the code

// We would normally return None and the request and not panic!

The current situation is return thread_id or panic!, but practically we should not panic!, am I right?

Jaxx4Fun avatar Aug 18 '20 15:08 Jaxx4Fun

Yeah, the right thing would be to either return None and let the caller decide what to do when there are no available threads, or implement some logic that queues the request for a thread and returns once it's available. Panicking this way is bad but accetable since we're just creating a simple example.

That's also a bad sentence on my part, it shuld be: // We would normally return None and not panic!. I'll correct that as well.

cfsamson avatar Aug 19 '20 08:08 cfsamson