Statistics
| Branch: | Tag: | Revision:

sssimulator / EventScheduler @ master

Name Size Revision Age Author Comment
  Test 0bf1a874 about 4 years Luca Baldesi add priority flag to events if events have sam...
Makefile 178 Bytes af271552 about 4 years luca add event scheduler
README 2.44 KB bf3d3ebd about 4 years Luca Baldesi refactor action event initialization and standa...
action_event.c 978 Bytes bf3d3ebd about 4 years Luca Baldesi refactor action event initialization and standa...
action_event.h 556 Bytes af271552 about 4 years luca add event scheduler
action_event_struct.h 551 Bytes bf3d3ebd about 4 years Luca Baldesi refactor action event initialization and standa...
event_scheduler.c 2.9 KB f1158e5c over 2 years Luca Baldesi Refactor Makefile
event_scheduler.h 798 Bytes bf3d3ebd about 4 years Luca Baldesi refactor action event initialization and standa...
gpl-3.0.txt 34.3 KB af271552 about 4 years luca add event scheduler
ord_array.c 4.95 KB a79ee600 about 4 years Luca Baldesi fix bug in ord_array position selection
ord_array.h 596 Bytes af271552 about 4 years luca add event scheduler

Latest revisions

# Date Author Comment
f1158e5c 04/21/2017 08:51 AM Luca Baldesi

Refactor Makefile

bf3d3ebd 07/31/2015 07:53 AM Luca Baldesi

refactor action event initialization and standardize event priority

two default priority levels are defined: HIGH_EVENT_PRIORITY and LOW_EVENT_PRIORITY

0bf1a874 07/30/2015 01:46 PM Luca Baldesi

add priority flag to events

if events have same time the new one is pushed in the last position possible (FIFO)
the priority flag can be used to override this behaviour

a79ee600 07/30/2015 01:43 PM Luca Baldesi

fix bug in ord_array position selection

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.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, your_special_function, your_destroyer_function); ye->custom_value = cv return (action_event *)ye; } void your_destroyer_function(struct action_event ** evt) { struct your_event * ye; ye = (struct your_event *) *evt; free(ye); *evt = NULL; } /* definition of your_special_function*/

Also available in: Atom