iddm / thread-priority

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

macOS support #9

Closed paulirotta closed 2 years ago

paulirotta commented 4 years ago

Recent changes are tested in Windows. No apparently problems. Excellent!

This PR add a stub for macOS to eliminate the need for runtime platform checks. Instead a specific new exception type is thrown for UnsupportedPlatform while still allowing compilation despite C stdlib differences from Unix standard.

I've assumed that macOS is the exception to platform family "unix". An alternative would be that "linux" is the only platform supporting our threading constructs- not sure, but a reasonable guess which works either way.

Some of the documentation examples needed simplification to avoid "docs are always on Linux, so the old example assertions in docs were not true due to UnsupportedPlatform" when running tests on mac. Thus you likely want to bump the secondary version number for any release.

iddm commented 4 years ago

Let it be failing then :) I'll implement the macos part this week.

On Mon, 23 Mar 2020 at 19:18, Paul Houghton notifications@github.com wrote:

@paulirotta commented on this pull request.

In src/lib.rs https://github.com/vityafx/thread-priority/pull/9#discussion_r396659869:

@@ -7,21 +7,25 @@ //! ```rust //! use thread_priority::*; //! -//! assert!(set_current_thread_priority(ThreadPriority::Min).is_ok()); +//! let result = set_current_thread_priority(ThreadPriority::Min);

On macOS it blows an error because the implementation there is a stub

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vityafx/thread-priority/pull/9#discussion_r396659869, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIX4AIIXTVDRMU2MWQUZMTRI6RVNANCNFSM4LSBLIAQ .

-- Best, Victor Polevoy.

paulirotta commented 4 years ago

Excellent

cwfitzgerald commented 3 years ago

Any progress on this front, while not required for my use case, it would be very nice for this to also work on mac.

iddm commented 3 years ago

Hi @cwfitzgerald,

Unfortunately, not much progress. I did some a while ago (after my last post here), but have never committed the changes and pushed. Haven't really had enough time between my projects to finally do something about it. Should you wish to work on it yourself, you are always welcome, but from my side I can't really tell when this can happen. If there were a simple and known solution to that, I'd finish it within a day, but the macOS's posix compatibility is not straightforward, and they are using cocoa to manage threads, so this required (and still requires as I have already forgotten my previous research results again) an investigation into the macOS thread management (and the best way to implement it here).

iddm commented 2 years ago

I am trying to add the same support as we have for Linux for macOS. Check this out: https://github.com/vityafx/thread-priority/pull/16

iddm commented 2 years ago

Closing this in favour of https://github.com/vityafx/thread-priority/pull/16 I also thank everyone here for your contribution! I really appreciate your feedback and effort, and I am glad you spent your time with me on making this crate a little bit better. Hope you are well!