Setting thread priority

Crate " thread-priority" allows setting thread priority cross-platform. Windows and Linux are covered, but not MacOS, probably because the developer lacks access to a MacOS machine. It's been stuck there since 2017. Is there another way to set thread priority? I just want to run some background stuff at a lower priority.

For macOS GCD has low-priority queues Dispatch — Rust API for macOS/iOS/iPadOS // Lib.rs

I'm not looking for a way to access an Apple-specific API. I have cross-platform code, but want to make some threads run at lower priority than others. The screen refresh thread needs to have priorit over the asset fetching and decompressing threads.

Looks like a system call to do this on MacOS is setpriority. I’ve never tried this so no idea if it works.

setpriority

libc::setpriority

If nobody has written a library for this that abstracts over every platform you want to cover, you can roll your own implementation that calls the dispatch crate (or something else, like the libc function @drewkett linked) on macOS and the thread-priority crate elsewhere, using conditional compilation.

What I was looking for is something that would work cross-compiled to Macs without my having to have one to debug. That's what "thread-priority" is supposed to do, but nobody ever did the Mac port.

Right, I was clarifying how @kornel's response could still be relevant/useful even if it's not exactly what you're looking for.