Mercurial > hg > Game > Cerium
view example/post_function/main.cc @ 400:984e7890db0c draft
Fix examples.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 21 Sep 2009 18:47:06 +0900 |
parents | c29b7163d6d9 |
children | d6ba5ede4fe7 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "TaskManager.h" #include "Func.h" extern void task_init(void); static TaskManager *manager; static int count = 1; const char *usr_help_str = "Usage: ./post [-cpu spe_num] [-count N]\n\ -count Number of print \"Hello, World!!\""; void func1(void *p) { int i = (int)p; printf("post function : %d\n", i--); if (i > 0) { HTaskPtr next = manager->create_task(HELLO_TASK); next->add_param(i); next->set_post(func1, (void*)i); next->set_cpu(SPE_ANY); next->spawn(); } } int init(int argc, char **argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-count") == 0) { count = atoi(argv[++i]); } } return 0; } void run_init(TaskManager *manager) { HTaskPtr task; task = manager->create_task(HELLO_TASK); task->add_param(count); task->set_post(func1, (void*)count); task->set_cpu(SPE_ANY); task->spawn(); } int TMmain(TaskManager *manager_, int argc, char *argv[]) { manager = manager_; if (init(argc, argv) < 0) { return -1; } task_init(); run_init(manager); return 0; }