You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/include/llarp/timer.h

39 lines
906 B
C

6 years ago
#ifndef LLARP_TIMER_H
#define LLARP_TIMER_H
#include <llarp/common.h>
#include <llarp/threadpool.h>
#ifdef __cplusplus
extern "C" {
#endif
6 years ago
typedef void (*llarp_timer_handler_func)(void *, uint64_t, uint64_t);
6 years ago
6 years ago
struct llarp_timeout_job {
uint64_t timeout;
void *user;
llarp_timer_handler_func handler;
};
6 years ago
6 years ago
struct llarp_timer_context;
6 years ago
6 years ago
struct llarp_timer_context *llarp_init_timer();
6 years ago
6 years ago
uint32_t llarp_timer_call_later(struct llarp_timer_context *t,
struct llarp_timeout_job job);
void llarp_timer_cancel(struct llarp_timer_context *t, uint32_t id);
// cancel all
void llarp_timer_stop(struct llarp_timer_context *t);
// blocking run timer and send events to thread pool
void llarp_timer_run(struct llarp_timer_context *t,
struct llarp_threadpool *pool);
void llarp_free_timer(struct llarp_timer_context **t);
6 years ago
#ifdef __cplusplus
}
#endif
#endif