001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj;
006
007import edu.wpi.first.hal.ThreadsJNI;
008
009public final class Threads {
010  /**
011   * Get the thread priority for the current thread.
012   *
013   * @return The current thread priority. For real-time, this is 1-99 with 99 being highest. For
014   *     non-real-time, this is 0. See "man 7 sched" for details.
015   */
016  public static int getCurrentThreadPriority() {
017    return ThreadsJNI.getCurrentThreadPriority();
018  }
019
020  /**
021   * Get if the current thread is real-time.
022   *
023   * @return If the current thread is real-time.
024   */
025  public static boolean getCurrentThreadIsRealTime() {
026    return ThreadsJNI.getCurrentThreadIsRealTime();
027  }
028
029  /**
030   * Sets the thread priority for the current thread.
031   *
032   * @param realTime Set to true to set a real-time priority, false for standard priority.
033   * @param priority Priority to set the thread to. For real-time, this is 1-99 with 99 being
034   *     highest. For non-real-time, this is forced to 0. See "man 7 sched" for details.
035   * @return True on success.
036   */
037  public static boolean setCurrentThreadPriority(boolean realTime, int priority) {
038    return ThreadsJNI.setCurrentThreadPriority(realTime, priority);
039  }
040
041  private Threads() {}
042}