1
0
mirror of https://github.com/CPunch/Laika.git synced 2024-11-24 13:31:05 +00:00
Laika/lib/include/ltask.h
CPunch 9694ae67d8 Added LAIKAPKT_PINGPONG
- shell now has it's own task service, it's polled in shellC_poll()
- default timeout for peers is 60 seconds, to change this edit the LAIKA_PEER_TIMEOUT in cnc.h
2022-04-13 12:19:06 -05:00

35 lines
1010 B
C

#ifndef LAIKA_TASK_H
#define LAIKA_TASK_H
#include <time.h>
struct sLaika_task;
struct sLaika_taskService;
typedef void (*taskCallback)(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData);
struct sLaika_task {
struct sLaika_task *next;
taskCallback callback;
void *uData;
long scheduled;
int delta;
};
struct sLaika_taskService {
struct sLaika_task *headTask;
};
void laikaT_initTaskService(struct sLaika_taskService *service);
void laikaT_cleanTaskService(struct sLaika_taskService *service);
struct sLaika_task *laikaT_newTask(struct sLaika_taskService *service, int delta, taskCallback callback, void *uData);
void laikaT_delTask(struct sLaika_taskService *service, struct sLaika_task *task);
void laikaT_pollTasks(struct sLaika_taskService *service);
/* will return the delta time in ms till the next event. -1 for no tasks scheduled */
int laikaT_timeTillTask(struct sLaika_taskService *service);
long laikaT_getTime(void);
#endif