iddm / thread-priority

A simple Cross-platform thread schedule and priority library for rust.
MIT License
110 stars 20 forks source link

add support for iOS target, use `pthread_setschedparam` on macOS target #26

Closed name1e5s closed 1 year ago

name1e5s commented 2 years ago

on apple targets, only pthread_setschedparam is allowed to upgrade threads to a higher priority. this PR change the implementation of set_thread_priority_and_policy_deadline on macOS and iOS targets to use pthread_setschedparam only.

Ref:

iddm commented 2 years ago

Thanks! A little bit of history here: initially, the code was written in a way almost precisely, just as you did. But then I found that some people really prefer niceness control as well, and I had to unify the code so that it works almost exactly the same everywhere. I also noticed in my test suite that macOS allowed much more than other unix systems. But I didn't know how much people wanted this to work on macOS, so I didn't know whether it would be better to leave it as it was for macOS or do it the same way everywhere. Your pull request here means that I was wrong and made a wrong decision. Thank you for correcting this back!

iddm commented 1 year ago

I've just pushed the changes from this PR, slightly adjusted. Feel free to open another PR if you want something else :-)