mirror of
https://github.com/CPunch/Laika.git
synced 2025-10-01 22:10:05 +00:00
Added TaskService, ltask.[ch]
- cnc's main.c has an example of scheduling tasks - switched to C11, might go back to C99 if i get the motivation to write a windows-specific getTime() implementation
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ltask.h"
|
||||
#include "cnc.h"
|
||||
|
||||
struct sLaika_taskService tService;
|
||||
|
||||
void debugTask(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData) {
|
||||
printf("hello !\n");
|
||||
}
|
||||
|
||||
int main(int argv, char **argc) {
|
||||
struct sLaika_cnc *cnc = laikaC_newCNC(13337);
|
||||
|
||||
laikaT_initTaskService(&tService);
|
||||
laikaT_newTask(&tService, 2000, debugTask, NULL);
|
||||
|
||||
while (true) {
|
||||
if (!laikaC_pollPeers(cnc, 1000)) {
|
||||
LAIKA_DEBUG("no events!\n");
|
||||
}
|
||||
laikaC_pollPeers(cnc, laikaT_timeTillTask(&tService));
|
||||
laikaT_pollTasks(&tService);
|
||||
}
|
||||
|
||||
laikaC_freeCNC(cnc);
|
||||
|
Reference in New Issue
Block a user