This thread is just a bunch of ideas flying around in my head, so feel free to either close this issue or comment on it. I'm fine with both ;)
Make a ThreadExt trait and implement the function set_priority and other with respect to the OS for std::thread::Thread.
This would make things seamless, e.g.
std::thread::current().set_thread_priority_and_policy(...)
You could also extend std::thread::Builder and have a function priority where you specify the priority beforehand.
Unify common functions.
What I mean by that is that currently I have to take a look into the unix mod to see what functions are available to me. This makes sense because unix might offer different things that windows does. But I would like to have a common struct/trait that combine the lowest common denominator. You can then do something sililar to what the std does by having a OS specific trait that extends your struct.
For an example what I mean look at std::fs::File with the AsRawFd and AsRawHandle traits.
Restrict the creation of invalid states.
I see that the ThreadPolicy enum can have an invalid state where when you pass a value beyond 100 to the Specific variant (btw. the documentation there says [0; 100] (read including 0 and 100), but the code says [0; 100) (read including 0, excluding 100). There needs to be a correction.
One way of doing this might be that the variant Specific does not hold a u32, but a struct SpecificNumber that has a new function which restricts the value passed to it and returning a Result.
Second would be that ThreadPolicy is a struct containing a single, non-public, enum. Similar to this: https://stackoverflow.com/questions/28090120/can-i-create-private-enum-constructors.
This way you can have some functions not returning a Result anymore, because they can't fail.
Create a few examples in the repo.
People love examples and hate reading docs (although I love reading rust docs, because they are unified and so pleasent to read). But a dedicated examples folder with just one example would spice things up and let people investigate everything they can do with this crate without looking into every function available.
Let me know what you think about this.
This crate looks nice and it perfectly fits into my current project. So thank you for developing it :)
This thread is just a bunch of ideas flying around in my head, so feel free to either close this issue or comment on it. I'm fine with both ;)
Make a
ThreadExttrait and implement the functionset_priorityand other with respect to the OS forstd::thread::Thread.This would make things seamless, e.g.
You could also extend
std::thread::Builderand have a functionprioritywhere you specify the priority beforehand.Unify common functions.
What I mean by that is that currently I have to take a look into the unix mod to see what functions are available to me. This makes sense because unix might offer different things that windows does. But I would like to have a common struct/trait that combine the lowest common denominator. You can then do something sililar to what the std does by having a OS specific trait that extends your struct.
For an example what I mean look at
std::fs::Filewith theAsRawFdandAsRawHandletraits.Restrict the creation of invalid states.
I see that the
ThreadPolicyenum can have an invalid state where when you pass a value beyond 100 to theSpecificvariant (btw. the documentation there says [0; 100] (read including 0 and 100), but the code says [0; 100) (read including 0, excluding 100). There needs to be a correction.One way of doing this might be that the variant
Specificdoes not hold au32, but a structSpecificNumberthat has anewfunction which restricts the value passed to it and returning a Result.Second would be that
ThreadPolicyis a struct containing a single, non-public, enum. Similar to this: https://stackoverflow.com/questions/28090120/can-i-create-private-enum-constructors.This way you can have some functions not returning a Result anymore, because they can't fail.
Create a few examples in the repo.
People love examples and hate reading docs (although I love reading rust docs, because they are unified and so pleasent to read). But a dedicated examples folder with just one example would spice things up and let people investigate everything they can do with this crate without looking into every function available.
Let me know what you think about this.
This crate looks nice and it perfectly fits into my current project. So thank you for developing it :)