int rain_spawn(rain_ctx_t * ctx,const char * mod,const char *args,routine_t * rid) { assert(ctx); if(!ctx){ return RAIN_ERROR; } rain_ctx_t * new_ctx = rain_ctx_new(rain_ctx_getid(ctx),mod,args); if(new_ctx != NULL){ if(rid){ *rid = rain_ctx_getid(new_ctx); } return RAIN_OK; } return RAIN_ERROR; }
int main(int argc,char *argv[]) { assert(argc >=3); rain_log_init(); rain_ctx_init(154); char *dir = malloc(1024); getcwd(dir,1024); strcat(dir,"/routine/"); //printf("dir:%s %s %s %s\n",dir,argv[0],argv[1],argv[2]); rain_moudle_init(dir); free(dir); rain_timer_init(); rainRpcInit(); rain_life_queue_init(); rain_message_queue_init(); sig_init(); struct rain_ctx * ctx = rain_ctx_new(0,argv[1],argv[2]); if(ctx == NULL){ exit(-1); } //routine_t rid = rain_ctx_getid(ctx); int len = 4; pthread_t threads[len]; int i; for(i=0; i<len; i++){ pthread_create(&threads[i],NULL,worker,NULL); } timer_loop(NULL); /* pthread_t thread_ev; pthread_create(&thread_ev,NULL,evloop,NULL); for(i=0; i<len; i++){ pthread_join(threads[i],NULL); } pthread_join(thread_ev,NULL);*/ exit(0); }