Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThreadExt::set_priority_and_policy errors for deadline policy #42

Open
mmasque opened this issue Aug 6, 2024 · 1 comment
Open

ThreadExt::set_priority_and_policy errors for deadline policy #42

mmasque opened this issue Aug 6, 2024 · 1 comment

Comments

@mmasque
Copy link

mmasque commented Aug 6, 2024

Trying to pass a Deadline policy and Deadline priority to ThreadExt::set_priority_and_policy yields an error in the call made to set_thread_priority_and_policy_deadline: "Deadline policy given without deadline priority". This happens because set_priority_and_policy calls set_thread_priority_and_policy with a ThreadPriority::Crossplatform parameter and the passed policy parameter:

use std::time::Duration;
use thread_priority::*;
fn main() {
    let duration = Duration::from_secs(3);
    let thread_priority = ThreadPriority::Deadline {
        deadline: duration.clone(),
        runtime: duration.clone(),
        period: duration.clone(),
        flags: DeadlineFlags::empty(),
    };

    matches!(
        std::thread::current().set_priority_and_policy(
            ThreadSchedulePolicy::Realtime(RealtimeThreadSchedulePolicy::Deadline),
            thread_priority,
        ),
        Err(Error::Priority(
            "Deadline policy given without deadline priority."
        ))
    );
}
@iddm
Copy link
Owner

iddm commented Aug 6, 2024

Hi again!

Indeed. Thanks for reporting. Should be an easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants