Skip to content

Commit

Permalink
Add ksnetEvMgrInitialize
Browse files Browse the repository at this point in the history
  • Loading branch information
you-think-you-are-special committed Jul 18, 2019
1 parent 4c3e276 commit d52ce94
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/ev_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,34 @@ int ksnetEvMgrRun(ksnetEvMgrClass *ke) {
return 0;
}

void ksnetEvMgrInitialize(ksnetEvMgrClass *ke){
ke->timer_val = 0;
ke->idle_count = 0;
ke->idle_activity_count = 0;

if(!modules_init(ke)){
ksnetEvMgrFree(ke, 0); // Free class variables and watchers after run
exit(EXIT_FAILURE);
}

// Initialize idle watchers
ev_idle_init (&ke->idle_w, idle_cb);
ke->idle_w.data = ke->kc;

// Initialize Check activity watcher
ev_idle_init (&ke->idle_activity_w, idle_activity_cb);
ke->idle_activity_w.data = ke;

// Initialize and start main timer watcher, it is a repeated timer
ev_timer_init (&ke->timer_w, timer_cb, 0.0, KSNET_EVENT_MGR_TIMER);
ke->timer_w.data = ke;
ev_timer_start (ke->ev_loop, &ke->timer_w);

// Run event loop
ke->runEventMgr = 1;
}


/**
* Free ksnetEvMgrClass after run
*
Expand Down
2 changes: 1 addition & 1 deletion src/ev_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ const char *teoGetAppVersion(ksnetEvMgrClass *ke);

int remove_peer_addr(ksnetEvMgrClass *ke, __CONST_SOCKADDR_ARG addr);
int ksnetAllowAckEvent(ksnetEvMgrClass* ke, int allow);

void ksnetEvMgrInitialize(ksnetEvMgrClass *ke);

#ifdef __cplusplus
}
Expand Down

0 comments on commit d52ce94

Please sign in to comment.