Hello,
I committed in branch tmp/core_events a simple framework to execute callbacks by core in various cases. So far there are two defined events: for network data in and data out.
I used it for implementing a topo-hiding module that is transparent for script writer and cope with stateless/stateful module in the same way.
Now, about the new event framework.
The core stores a structure with pointers to event manager callbacks.
typedef int (*sr_event_cb_f)(void *data);
typedef struct sr_event_cb { sr_event_cb_f net_data_in; sr_event_cb_f net_data_out; } sr_event_cb_t;
The event manager can be implemented elsewhere, but the execution of call manager and implementation must be very tied. The event manager callback gets only one parameter, which is a void* and is specific per event, thus the implementation must know what is the content.
So far, only one listener is needed for network data in/out events, thus the event manager does the processing, but if the event should trigger more functions from different parts of code, then the manager must take of handling them (registration, execution, etc...).
You can download the branch and test the topoh module. It will be merged once we discuss and decide whether the new core events framework is the best for now, if something is missing, a.s.o.
Feedback is very much appreciated.
Cheers, Daniel