001/*----------------------------------------------------------------------------*/
002/* Copyright (c) 2016-2018 FIRST. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj.hal;
009
010/**
011 * The NotifierJNI class directly wraps the C++ HAL Notifier.
012 *
013 * <p>This class is not meant for direct use by teams. Instead, the edu.wpi.first.wpilibj.Notifier
014 * class, which corresponds to the C++ Notifier class, should be used.
015 */
016public class NotifierJNI extends JNIWrapper {
017  /**
018   * Initializes the notifier.
019   */
020  public static native int initializeNotifier();
021
022  /**
023   * Wakes up the waiter with time=0.  Note: after this function is called, all
024   * calls to waitForNotifierAlarm() will immediately start returning 0.
025   */
026  public static native void stopNotifier(int notifierHandle);
027
028  /**
029   * Deletes the notifier object when we are done with it.
030   */
031  public static native void cleanNotifier(int notifierHandle);
032
033  /**
034   * Sets the notifier to wakeup the waiter in another triggerTime microseconds.
035   */
036  public static native void updateNotifierAlarm(int notifierHandle, long triggerTime);
037
038  /**
039   * Cancels any pending wakeups set by updateNotifierAlarm().  Does NOT wake
040   * up any waiters.
041   */
042  public static native void cancelNotifierAlarm(int notifierHandle);
043
044  /**
045   * Block until woken up by an alarm (or stop).
046   * @return Time when woken up.
047   */
048  public static native long waitForNotifierAlarm(int notifierHandle);
049}