-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SystemLayer::PostEvent add API to post a lambda event #9678
Conversation
fdbe2c7
to
e7b82a2
Compare
ead9690
to
d7f9488
Compare
d7f9488
to
03efc11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
03efc11
to
15ebdcc
Compare
15ebdcc
to
a88a2d1
Compare
Size increase report for "gn_qpg-example-build" from 8e86c9e
Full report output
|
Size increase report for "nrfconnect-example-build" from 8e86c9e
Full report output
|
Size increase report for "esp32-example-build" from 8e86c9e
Full report output
|
Here's my belated feedback
[1] https://answers.launchpad.net/gcc-arm-embedded/+question/686870/+index |
It is not same as [1], his usage is obviously wrong, he called the constructor twice.
user_data doesn't contain type information, using lambda, the type information of the posted data will be encoded into the handler function.
There are
I'm not quite get this one, lambdas can be called multiple times, we can broadcast lambda object if we want.
it is a limitation of RToS xQueue API, The API can only post fixed size memory region. https://www.freertos.org/a00117.html
This PR provides a better interface than previous, more flexible and type-safe. It will still take time to migrate all legacy code into the new API. Once all usage are migrated, we can safely remove the enum
|
You don't need to migrate the call sites of PostEvent, you can keep those as is and make PostEvent convert the event to a lambda. All you need to do it is change the array of discriminated union of events and lambdas to an array only of lambdas and implement "dispatch event" as a lambda. The reason to do it is to make more efficient use of the space in the queue.
|
Problem
Provides a most flexible API to run a deferred function.
This will decouple system object from network endpoints (TCPEndpoint, UDPEndpoint). It helps implementing the system object pool in PR #9590
Change overview
Add a
PostLambda
to post a generic lambda into system event queue.There is several limitation of the lambda
memcpy
into the queue. It means that the lambda can only capture pod data (Including pointers).LambdaProxy<Lambda>::Call
, and resolved into a function pointer at compile time, assigned toLambdaBridge::LambdaProxy
into the queue element.Testing
Verified by unit tests.