3 ms·
Does the test runner actually pass any user-values between test threads?
by brundolf 4y ago
Does the test runner actually pass any user-values between test threads?
- steveklabnik 4y agoNot on its own. It’s basically “hey take these functions, each is a test, run them on multiple threads” and that’s it, nothing fancier.
- db48x 4y agoRight. It just affects other decisions about the language, like the type of static items. In a purely single–threaded program it would be ok if statics weren’t Sync, but it would be a lot of work for the compiler to verify that. And since every program needs tests anyway, it might as well always require them to be Sync and then it doesn’t have to check.
- steveklabnik 4y agoTotally. I take a slightly different view in the statics thing; like a static means you want something to be available across threads. So by using a static, you’re opening yourself to that possibility. If you want something global to a thread, use thread local storage, and Rust will allow you to use stuff that’s not okay if multiple threads were involved. It’s about expressing your intent correctly.
- brundolf 4y agoTIL thread local storage!