Add name to HAL Notifier

This commit is contained in:
Peter Johnson
2019-11-09 11:41:58 -08:00
parent 2da64d15f6
commit 3e049e02f0
10 changed files with 74 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
#include "hal/Notifier.h"
#include <chrono>
#include <string>
#include <wpi/condition_variable.h>
#include <wpi/mutex.h>
@@ -20,6 +21,7 @@
namespace {
struct Notifier {
std::string name;
uint64_t waitTime;
bool updatedAlarm = false;
bool active = true;
@@ -71,6 +73,14 @@ HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status) {
return handle;
}
void HAL_SetNotifierName(HAL_NotifierHandle notifierHandle, const char* name,
int32_t* status) {
auto notifier = notifierHandles->Get(notifierHandle);
if (!notifier) return;
std::scoped_lock lock(notifier->mutex);
notifier->name = name;
}
void HAL_StopNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
auto notifier = notifierHandles->Get(notifierHandle);
if (!notifier) return;