Statistics
| Branch: | Tag: | Revision:

sssimulator / EventScheduler @ af271552

Name Size Revision Age Author Comment
  Test af271552 over 6 years luca add event scheduler
Makefile 178 Bytes af271552 over 6 years luca add event scheduler
README 2.41 KB af271552 over 6 years luca add event scheduler
action_event.c 925 Bytes af271552 over 6 years luca add event scheduler
action_event.h 556 Bytes af271552 over 6 years luca add event scheduler
action_event_struct.h 426 Bytes af271552 over 6 years luca add event scheduler
event_scheduler.c 2.83 KB af271552 over 6 years luca add event scheduler
event_scheduler.h 720 Bytes af271552 over 6 years luca add event scheduler
gpl-3.0.txt 34.3 KB af271552 over 6 years luca add event scheduler
ord_array.c 4.68 KB af271552 over 6 years luca add event scheduler
ord_array.h 596 Bytes af271552 over 6 years luca add event scheduler

Latest revisions

# Date Author Comment
af271552 07/23/2015 05:07 PM luca

add event scheduler

View revisions

README


Simple Scalable Event Scheduler (SSES) is a C language framework for dealing with events. The basic event is called "action_event" because it can be associated with a function (event trigger). Event can be customized and used in the framework by extending action_event. The priority queue is implemented with buffer ring called ord_array. ord_array pop requires constant time while insertion linear time. However the constant in this operation is very small since it is performed a stdlib memmove. Moreover if insertions regard events of deadline greater than any other event, operation time is constant. ---------------------UML "class" diagram------------------------------- +---------------+ +------------+ |event_scheduler|<>------------------------->|action_event| +---------------+ +------------+ | A | | v | +---------+ +------------+ |ord_array| || +---------+ +------------+ ---------------------Basic usage--------------------------------------- struct event_scheduler * es; struct action_event * ev; es = event_scheduler_new(0); //creation of an event_scheduler ev = action_event_new(your_func); //creation of an action_event with custom func res = event_scheduler_insert(es,ev,1); //schedule event from 1 time unit from now /*....*/ ev = event_scheduler_pop(es); //get next event in the queue action_event_trigger(ev); //execute custom func action_event_destroy(&ev); --------------------Adv usage------------------------------------------- Since most of the time you probably want to associate a state to an event SSES has been designed with extensibility in mind. /*your_event.h*/ #include"action_event_struct.h" struct your_event { struct action_event base; int custom_value; } struct action_event * your_event_new(int cv) { struct your_event * ye; ye = (struct your_event *) malloc(sizeof(struct your_event)); action_event_init((struct action_event *) ye, NULL); ye->custom_value = cv ye->trigger = your_special_function; ye->destroy = your_destroyer_function; //useful if dynamic extra data is used return (action_event *)ye; } /* definition of your_special_function and your_destroyer_function */

Also available in: Atom