-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCpuSpinner.h
46 lines (34 loc) · 812 Bytes
/
CpuSpinner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// CpuSpinner.h
#ifndef _CPUSPINNER_h
#define _CPUSPINNER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
typedef void(*CallbackFunc)(void *instance);
struct CallbackSetup {
void *instance;
CallbackFunc callbackFn;
CallbackSetup(void *instance, CallbackFunc callbackFn)
: instance(instance), callbackFn(callbackFn)
{ }
void Invoke() {
this->callbackFn(this->instance);
}
};
struct CallbackRegistration {
CallbackSetup callback;
CallbackRegistration *next;
CallbackRegistration(const CallbackSetup& callbackSetup)
: callback(callbackSetup), next(NULL)
{ }
};
class CpuSpinner {
public:
static void RequestUpdate(const CallbackSetup &callbackSetup);
static void Update();
private:
static CallbackRegistration* callbackRoot;
};
#endif