mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Update to 2018_v4 image and new build system. (#598)
* Revert "Force OpenCV to 3.1.0 (#602)"
This reverts commit 50ed55e8e2.
* Removes Simulation
* Removes old build system
* Removes old gtest
* Adds new gmock and gtest
* Updates to new ni-libraries
* removes MyRobot (to be replaced)
* moves files to new location
* Adds new sim backend and new test executables
* updates .styleguide and .gitignore
* Changes cpp WPILibVersion to a function
MSVC throws an AV with the old version.
* Disables USBCamera on all systems except for linux
* 2018 NI Libraries
* New build system
This commit is contained in:
committed by
Peter Johnson
parent
50ed55e8e2
commit
e1195e8b9d
64
wpilibc/src/main/native/include/Notifier.h
Normal file
64
wpilibc/src/main/native/include/Notifier.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "HAL/Notifier.h"
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
typedef std::function<void()> TimerEventHandler;
|
||||
|
||||
class Notifier : public ErrorBase {
|
||||
public:
|
||||
explicit Notifier(TimerEventHandler handler);
|
||||
|
||||
template <typename Callable, typename Arg, typename... Args>
|
||||
Notifier(Callable&& f, Arg&& arg, Args&&... args)
|
||||
: Notifier(std::bind(std::forward<Callable>(f), std::forward<Arg>(arg),
|
||||
std::forward<Args>(args)...)) {}
|
||||
|
||||
virtual ~Notifier();
|
||||
|
||||
Notifier(const Notifier&) = delete;
|
||||
Notifier& operator=(const Notifier&) = delete;
|
||||
|
||||
void StartSingle(double delay);
|
||||
void StartPeriodic(double period);
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
// update the HAL alarm
|
||||
void UpdateAlarm();
|
||||
// HAL callback
|
||||
static void Notify(uint64_t currentTimeInt, HAL_NotifierHandle handle);
|
||||
|
||||
// used to constrain execution between destructors and callback
|
||||
static hal::priority_mutex m_destructorMutex;
|
||||
// held while updating process information
|
||||
hal::priority_mutex m_processMutex;
|
||||
// HAL handle, atomic for proper destruction
|
||||
std::atomic<HAL_NotifierHandle> m_notifier{0};
|
||||
// address of the handler
|
||||
TimerEventHandler m_handler;
|
||||
// the absolute expiration time
|
||||
double m_expirationTime = 0;
|
||||
// the relative time (either periodic or single)
|
||||
double m_period = 0;
|
||||
// true if this is a periodic event
|
||||
bool m_periodic = false;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user