This commit is contained in:
grcasanova
2020-07-06 00:54:30 +02:00
parent 0a6059ba13
commit d5b8038457
16 changed files with 144 additions and 105 deletions

View File

@@ -0,0 +1,26 @@
#pragma once
#include "PeriodicTask.h"
namespace concurrency {
/**
* @brief Periodically invoke a callback. This just provides C-style callback conventions
* rather than a virtual function - FIXME, remove?
*/
class Periodic : public PeriodicTask
{
uint32_t (*callback)();
public:
// callback returns the period for the next callback invocation (or 0 if we should no longer be called)
Periodic(uint32_t (*_callback)()) : callback(_callback) {}
protected:
void doTask() {
uint32_t p = callback();
setPeriod(p);
}
};
} // namespace concurrency