Added functions to register callbacks to the param_sniffer()#49
Added functions to register callbacks to the param_sniffer()#49kivkiv12345 wants to merge 1 commit intomasterfrom
param_sniffer()#49Conversation
| int param_sniffer_log(void * ctx, param_queue_t *queue, param_t *param, int offset, void *reader, csp_timestamp_t *timestamp); | ||
| void param_sniffer_init(int add_logfile); | ||
|
|
||
| /* TODO Kevin: We should probably pass along `*queue`, `offset` and `*timestamp` as well. */ |
There was a problem hiding this comment.
If we "probably should", why not do it ? :)
There was a problem hiding this comment.
I take it you agree then? I will do it!
|
|
||
| int param_sniffer_register_callback(param_sniffer_callback_f callback, void * context) { | ||
|
|
||
| /* TODO Kevin: What about registering the same callback multiple times? What if it has different contexts? */ |
There was a problem hiding this comment.
What about that ? This is a way for users of this API to register things, we can't be responsible for what they actually register, can we ?
There was a problem hiding this comment.
I left that comment wondering how I should handle it in param_sniffer_UNregister_callback(). Do we unregister all callbacks to that function, or only the first match?
Do we error if that function is already registered?
There was a problem hiding this comment.
A solution would be to update the
int param_sniffer_unregister_callback(param_sniffer_callback_f callback)
to:
int param_sniffer_unregister_callback(param_sniffer_callback_f callback, void * context)
and then test for both the callbackand contextto find the correct element to unregister...
|
@jeanbaptistelab Maybe it's overkill to hide SLIST? Especially since I've been considering exposing the callback collection itself as well. But I think that can be a future addition :) |
This is your chance to stop me @troelsjessen! :)
There's still a couple of things I want to change.
But if you have any major grievances with the general concept, you can let me know before I continue.
I've tested it ad-hoc, with the following function/callbacks:
pullafter callingregister_callbacks():Pull after calling
unregister_callbacks():Valgrind tested, no errors.