mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[cscore] Fix Java direct callback notifications (#3631)
These relied on the OnStart and OnExit callbacks which were not present in the wpiutil common CallbackManager code. Add support for these and fix up other use cases. Also fixes notifications to correctly filter on event kind. This fixes a breakage caused by #3133.
This commit is contained in:
@@ -35,8 +35,11 @@ struct ListenerData : public wpi::CallbackListenerData<
|
||||
class NotifierThread
|
||||
: public wpi::CallbackThread<NotifierThread, RawEvent, ListenerData> {
|
||||
public:
|
||||
bool Matches(const ListenerData& /*listener*/, const RawEvent& /*data*/) {
|
||||
return true;
|
||||
NotifierThread(std::function<void()> on_start, std::function<void()> on_exit)
|
||||
: CallbackThread(std::move(on_start), std::move(on_exit)) {}
|
||||
|
||||
bool Matches(const ListenerData& listener, const RawEvent& data) {
|
||||
return (data.kind & listener.eventMask) != 0;
|
||||
}
|
||||
|
||||
void SetListener(RawEvent* data, unsigned int listener_uid) {
|
||||
|
||||
@@ -708,9 +708,13 @@ void ReleaseSink(CS_Sink sink, CS_Status* status) {
|
||||
// Listener Functions
|
||||
//
|
||||
|
||||
void SetListenerOnStart(std::function<void()> onStart) {}
|
||||
void SetListenerOnStart(std::function<void()> onStart) {
|
||||
Instance::GetInstance().notifier.SetOnStart(onStart);
|
||||
}
|
||||
|
||||
void SetListenerOnExit(std::function<void()> onExit) {}
|
||||
void SetListenerOnExit(std::function<void()> onExit) {
|
||||
Instance::GetInstance().notifier.SetOnExit(onExit);
|
||||
}
|
||||
|
||||
static void StartBackground(int eventMask, bool immediateNotify) {
|
||||
auto& inst = Instance::GetInstance();
|
||||
|
||||
Reference in New Issue
Block a user