Rewrite Java Notifier and update Interrupt JNI.

Notifier takes advantage of the multi-notifier support now in HAL.

Each Notifier is now handled by a separate thread at the JNI level, so
one notifier taking longer to process (or being breakpointed) does not
stop the other notifiers from running.  These threads are configured as
daemon threads.

In both Notifier and Interrupt JNI, the JNI thread attachment no longer
repeatedly calls AttachCurrentThread().  This improves performance but more
importantly avoids impacting the Eclipse debugger, which attempts to
track each call to AttachCurrentThread() as a separate Java thread.

Note: There is currently no way to free an interrupt handler.  Repeatedly
calling attachInterruptHandler() will result in leaking previous handlers.

Change-Id: Ib12e3df88943c03e0269d3906e5b153767139391
This commit is contained in:
Peter Johnson
2015-12-17 16:19:44 -08:00
parent 416a238bed
commit 5dc5ed83b3
8 changed files with 564 additions and 429 deletions

View File

@@ -59,9 +59,9 @@ static void cleanupNotifierAtExit() {
notifierManager = nullptr;
}
void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), void *param, int32_t *status)
void* initializeNotifier(void (*process)(uint32_t, void*), void *param, int32_t *status)
{
if (!ProcessQueue) {
if (!process) {
*status = NULL_PARAMETER;
return nullptr;
}
@@ -85,7 +85,7 @@ void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), void *param, int
notifier->next = notifiers;
if (notifier->next) notifier->next->prev = notifier;
notifier->param = param;
notifier->process = ProcessQueue;
notifier->process = process;
notifiers = notifier;
return notifier;
}
@@ -119,6 +119,11 @@ void cleanNotifier(void* notifier_pointer, int32_t *status)
}
}
void* getNotifierParam(void* notifier_pointer, int32_t *status)
{
return ((Notifier*)notifier_pointer)->param;
}
void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *status)
{
std::lock_guard<priority_recursive_mutex> sync(notifierMutex);
@@ -141,3 +146,10 @@ void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *
notifierInterruptMutex.unlock();
}
void stopNotifierAlarm(void* notifier_pointer, int32_t *status)
{
std::lock_guard<priority_recursive_mutex> sync(notifierMutex);
Notifier* notifier = (Notifier*)notifier_pointer;
notifier->triggerTime = UINT32_MAX;
}