--- libaitsched/example/test.c 2011/08/12 23:06:55 1.1.2.1 +++ libaitsched/example/test.c 2011/08/13 17:17:08 1.1.2.2 @@ -1,16 +1,65 @@ #include +#include +#include +#include +#include +#include +#include #include void *event(void *arg) { + printf("Event::\n"); return NULL; } +void *eventlo(void *arg) +{ + printf("EventLOW::\n"); + return NULL; +} + +void *timer(void *arg) +{ + printf("Timer 10sec::\n"); + return NULL; +} + +void *r(void *arg) +{ + printf("read::\n"); + return NULL; +} + +void *w(void *arg) +{ + printf("write::\n"); + return NULL; +} + +void *once(void *arg) +{ + printf("once::\n"); + return NULL; +} + int main(int argc, char **argv) { sched_root_task_t *root; + int f; + struct sockaddr_in sin; + f = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (f == -1) + return 1; + sin.sin_len = sizeof sin; + sin.sin_family = AF_INET; + sin.sin_port = htons(2345); + sin.sin_addr.s_addr = INADDR_ANY; + if (bind(f, (struct sockaddr*) &sin, sizeof sin) == -1) + return 1; + root = schedBegin(); if (!root) { printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); @@ -22,6 +71,31 @@ main(int argc, char **argv) return 2; } + if (!schedEventLo(root, eventlo, "piuk", 1111)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 3; + } + + if (!schedTimer(root, timer, "blah", 10000000)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 4; + } + + if (!schedRead(root, r, "rrr", f)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 5; + } + + if (!schedWrite(root, w, "www", f)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 6; + } + + schedCallOnce(root, once, "000000", 42); + + schedRun(root); schedEnd(root); + + close(f); return 0; }