Capturing events/signals in delegate/worker threads
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Capturing events/signals in delegate/worker threads
Hi,
You mean while doing chDelegateDispatch() ?
Giovanni
You mean while doing chDelegateDispatch() ?
Giovanni
Re: Capturing events/signals in delegate/worker threads
Something like:
You would need something to allocate event ids, and register a callback for each ID. chEvtDispatch() can be used to process the incoming events. Just need an API to populate the eventhandler_t[], and return back an allocated eventid and thread_t - which the client can then go and give to event sources.
Code: Select all
/* from client - the eventual handler for the event */
void callback_on_event (void) {
/* This gets called by the delegate/worker thread
* once the event is generated by other_module_generate_event()
*/
}
void setup_callback_on_event() {
thread_t * thd;
event_id id;
chDelegate_allocate_thread_signal (&thd, &id, callback_on_event);
other_module_use_this_thread_signal(thd, id);
}
/* in other module which generates the event */
void other_module_use_this_thread_signal(thread_t * thd, eventid_t id) {
stored_thd = thd;
stored_id = id;
}
void other_module_generate_event (void) {
chEvtSignal(stored_thd, EVENT_MASK(stored_id))
}
You would need something to allocate event ids, and register a callback for each ID. chEvtDispatch() can be used to process the incoming events. Just need an API to populate the eventhandler_t[], and return back an allocated eventid and thread_t - which the client can then go and give to event sources.
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 49 guests