HAL: Add support for multiple Notifiers.

This is a poor man's version of the multi-instance Notifier support in
the higher level languages.  It's intended primarily so that notifiers
can be created internal to the HAL.

One benefit of this change is that the current FPGA timestamp is passed
as the first parameter to the ProcessQueue function (rather than the
useless interrupt mask).

Caution for other languages wrapping the HAL: this adds a parameter to
initializeNotifier().

An atexit hook is used for safe cleanup at program termination.

Change-Id: I782b3a74c10215588ae9b7191906fb4186a81028
This commit is contained in:
Peter Johnson
2015-11-21 22:17:11 -08:00
parent 07be45af80
commit 03c43a46d7
4 changed files with 129 additions and 26 deletions

View File

@@ -22,7 +22,7 @@ static jmethodID mid_global;
// The arguments are unused by the HAL Notifier; they just satisfy a particular
// function signature.
void notifierHandler(uint32_t mask, void* param) {
void notifierHandler(uint32_t currentTimeInt, void* param) {
jobject handler_obj = func_global;
jmethodID mid = mid_global;
@@ -82,7 +82,7 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_NotifierJNI_initializeNot
mid_global = mid;
int32_t status = 0;
void *notifierPtr = initializeNotifier(notifierHandler, &status);
void *notifierPtr = initializeNotifier(notifierHandler, nullptr, &status);
NOTIFIERJNI_LOG(logDEBUG) << "Notifier Ptr = " << notifierPtr;
NOTIFIERJNI_LOG(logDEBUG) << "Status = " << status;