mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Add a function for getting the current priority
This commit is contained in:
@@ -31,6 +31,16 @@ fs::path get_temporary_directory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<int> get_scheduling_priority() {
|
||||||
|
sched_param current_params{};
|
||||||
|
if (sched_getparam(0, ¤t_params) == 0 &&
|
||||||
|
current_params.sched_priority > 0) {
|
||||||
|
return current_params.sched_priority;
|
||||||
|
} else {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool set_realtime_priority(bool sched_fifo) {
|
bool set_realtime_priority(bool sched_fifo) {
|
||||||
sched_param params{.sched_priority = 5};
|
sched_param params{.sched_priority = 5};
|
||||||
return sched_setscheduler(0, sched_fifo ? SCHED_FIFO : SCHED_OTHER,
|
return sched_setscheduler(0, sched_fifo ? SCHED_FIFO : SCHED_OTHER,
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ overload(Ts...) -> overload<Ts...>;
|
|||||||
*/
|
*/
|
||||||
boost::filesystem::path get_temporary_directory();
|
boost::filesystem::path get_temporary_directory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current thread's scheduling priority if the thread is using
|
||||||
|
* `SCHED_FIFO`. Returns a nullopt of the calling thread is not under realtime
|
||||||
|
* scheduling.
|
||||||
|
*/
|
||||||
|
std::optional<int> get_scheduling_priority();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the scheduling policy to `SCHED_FIFO` with priority 10 for this process.
|
* Set the scheduling policy to `SCHED_FIFO` with priority 10 for this process.
|
||||||
* We explicitly don't do this for wineserver itself since from my testing that
|
* We explicitly don't do this for wineserver itself since from my testing that
|
||||||
|
|||||||
Reference in New Issue
Block a user