Class Notifier
- All Implemented Interfaces:
AutoCloseable
public class Notifier extends Object implements AutoCloseable
If startSingle() is used, the callback will run once. If startPeriodic() is used, the callback will run repeatedly with the given period until stop() is called.
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
close()
void
setCallback(Runnable callback)
Change the callback function.static boolean
setHALThreadPriority(boolean realTime, int priority)
Sets the HAL notifier thread priority.void
setHandler(Runnable callback)
Deprecated, for removal: This API element is subject to removal in a future version.Use setCallback() instead.void
setName(String name)
Sets the name of the notifier.void
startPeriodic(double periodSeconds)
Run the callback periodically with the given period.void
startSingle(double delaySeconds)
Run the callback once after the given delay.void
stop()
Stop further callback invocations.
-
Constructor Details
-
Notifier
Create a Notifier with the given callback.Configure when the callback runs with startSingle() or startPeriodic().
- Parameters:
callback
- The callback to run.
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
setName
Sets the name of the notifier. Used for debugging purposes only.- Parameters:
name
- Name
-
setHandler
Deprecated, for removal: This API element is subject to removal in a future version.Use setCallback() instead.Change the callback function.- Parameters:
callback
- The callback function.
-
setCallback
Change the callback function.- Parameters:
callback
- The callback function.
-
startSingle
Run the callback once after the given delay.- Parameters:
delaySeconds
- Time in seconds to wait before the callback is called.
-
startPeriodic
Run the callback periodically with the given period.The user-provided callback should be written so that it completes before the next time it's scheduled to run.
- Parameters:
periodSeconds
- Period in seconds after which to to call the callback starting one period after the call to this method.
-
stop
Stop further callback invocations.No further periodic callbacks will occur. Single invocations will also be cancelled if they haven't yet occurred.
If a callback invocation is in progress, this function will block until the callback is complete.
-
setHALThreadPriority
Sets the HAL notifier thread priority.The HAL notifier thread is responsible for managing the FPGA's notifier interrupt and waking up user's Notifiers when it's their time to run. Giving the HAL notifier thread real-time priority helps ensure the user's real-time Notifiers, if any, are notified to run in a timely manner.
- Parameters:
realTime
- Set to true to set a real-time priority, false for standard priority.priority
- Priority to set the thread to. For real-time, this is 1-99 with 99 being highest. For non-real-time, this is forced to 0. See "man 7 sched" for more details.- Returns:
- True on success.
-