sock: initial definitions for asynchronous event handling#11723
sock: initial definitions for asynchronous event handling#11723miri64 merged 1 commit intoRIOT-OS:masterfrom
Conversation
|
Nice move forward! Some thoughts (only brief look):
If I see correctly, there's one "ctx" per sock, and thus one event object. If now there are multiple events (CAN_READ | CLOSED), the second that arrives overwrites the first. The event should be used as bitfield, and it should be set in a way that even if the event is already queued, a subsequent bit that gets set can still be read.
I think we might get away with just ifdef'ing support for the different event methods, without resorting to custom types. |
I was thinking about this, actually even had some header definitions for that however those were transparent to the lower levels of the implementation and thus did not really simplify things. Everything beyond that would rather be a completely new API, which would not
They will be. By the lower level implementation. As you can see for
There are ways to prevent that (e.g. making sure the callback is only once and then again after an event was handled)
As pointed out above: I'm against changing the current API (apart from amendments and minor changes) at this point.
That is the idea of |
|
Another reason against using a "generic sock" here would be that it then wouldn't be applicable for TCP listener queues. |
|
I added another example implementation using |
|
Very nice, can't wait to have axync sock! I am not 100% sure if I understood the code correctly, but I don't like the direct mapping to We can then use this 'lower-level' to implement the usual convenience wrappers for concrete IPC implementations ( If this is already the case and I just did not read the code of this PR correctly then never mind :-) |
There is no direct mapping to |
Sorry, should have read your comment to the very end 😅. Yes, what you are proposing is already the case. |
|
Now I saw, I mainly missed the difference of |
c928fbd to
77534b1
Compare
|
I gave this PR some well deserved love:
All that's missing is some doc on the |
|
Added some doc for |
|
OK. I updated all the doc now. Anybody wants to review. I did not test, if the examples I provide work, as there is no implementation of this API yet, but I'd be happy to provide one for GNRC and lwIP, once I get some positive feedback. |
|
If people prefer it, I can factor out the example front-end implementations into separate PRs. |
|
@haukepetersen @kaspar030 et al. can I please have some feedback on this? |
| ctx->event.sock = sock; | ||
| ctx->event.type |= type; | ||
| event_post(ctx->queue, &ctx->event.super); | ||
| ctx->event.type &= ~type; |
There was a problem hiding this comment.
this must stay set until after the cb has been executed.
|
@kaspar030 and I discussed a bit about this online and we decided to take out the the front-end implementations for now for several reason:
As this needs some cherry-picking and reverting I will go ahead and squash everything. |
3f7c83b to
1930d5b
Compare
|
Squashed first (and renamed the event type flags as they caused some confusion offline) |
1930d5b to
2ffb895
Compare
|
And squashed and renamed again (forgot to rename the usage of that type) |
2ffb895 to
1281d15
Compare
|
Aand removed the implementations. Ready for review again. |
|
Pushed also some doc adaptions to be more in line with the new name. |
sys/include/net/sock.h
Outdated
| * @note Only applicable with @ref SOCK_HAS_ASYNC defined. | ||
| */ | ||
| typedef enum { | ||
| SOCK_EVENT_CONN_RDY = 0x0001, /**< Connection ready event */ |
sys/include/net/sock/dtls.h
Outdated
|
|
||
| #if SOCK_HAS_ASYNC_CTX || defined(DOXYGEN) | ||
| /** | ||
| * @brief Gets the asynchronous |
kaspar030
left a comment
There was a problem hiding this comment.
Looks very promising!
We discussed offline that while this API is not stable we'll keep it separate from the existing sock headers and just copy all changes from this PR into a shared sock/async.h.
That way existing code, API and headers stay untouched for now.
bb596b9 to
f0b5eb0
Compare
Done and squashed (as I removed most commits anyway). |
kaspar030
left a comment
There was a problem hiding this comment.
ACK. Great starting point.
|
Thanks for reviewing and getting this finally in! |
Contribution description
This represents another approach to asynchronous sock as outlined in #8149 (comment). Apart from the necessary definitions for all basic sock types, this PR also contains example implementations for
event.handmsg.hwhich can also be separated out into another PR.Testing procedure
No implementation in this PR, just API (and a implementations using this unimplemented API ;-)).
Issues/PRs references
Alternative to #8149.