timer.h 790 Bytes
Newer Older
Stefan Reif's avatar
Stefan Reif committed
1
2
3
4
5
6
7
8
#ifndef PRRT_TIMER_H
#define PRRT_TIMER_H

#include <pthread.h>
#include <stdatomic.h>
#include "../util/futex.h"
#include "../util/list.h"

Stefan Reif's avatar
Stefan Reif committed
9
10
11
12
typedef void *prrtTimerTaskArg;
typedef void (*prrtTimerTaskFun)(prrtTimerTaskArg);

typedef struct timespec prrtTimerDate;
Stefan Reif's avatar
timer    
Stefan Reif committed
13
typedef unsigned long long TimerDateUDiff_t;
Stefan Reif's avatar
Stefan Reif committed
14

Stefan Reif's avatar
Stefan Reif committed
15
typedef struct prrtTimerTask {
Stefan Reif's avatar
Stefan Reif committed
16
17
	prrtTimerTaskFun fun;
	prrtTimerTaskArg arg;
Stefan Reif's avatar
Stefan Reif committed
18
19
} PrrtTimerTask;

Stefan Reif's avatar
Stefan Reif committed
20
typedef struct prrtTimer PrrtTimer;
Stefan Reif's avatar
Stefan Reif committed
21

Stefan Reif's avatar
Stefan Reif committed
22
PrrtTimer *PrrtTimer_create(unsigned int core);
Stefan Reif's avatar
Stefan Reif committed
23

Stefan Reif's avatar
Stefan Reif committed
24
int PrrtTimer_submit(PrrtTimer *timer, const prrtTimerDate *when, const PrrtTimerTask *what);
Stefan Reif's avatar
Stefan Reif committed
25
26
27

void PrrtTimer_end(PrrtTimer *timer);

Stefan Reif's avatar
timer    
Stefan Reif committed
28
29
30
void PrrtTimer_sleep_until(PrrtTimer *self, const prrtTimerDate *end);
void PrrtTimer_sleep_nanos(PrrtTimer *self, TimerDateUDiff_t nanos);

Stefan Reif's avatar
Stefan Reif committed
31
#endif // PRRT_TIMER_H