-
Notifications
You must be signed in to change notification settings - Fork 8
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
Adding non-blocking function to ndn_app API #5
base: master
Are you sure you want to change the base?
Conversation
I'm not sure about the intention for the new I kind of understand the use case for the |
I just want to handle several event loops at the same time in the same thread. |
I think by definition each thread should have only one event loop that runs forever within that thread. Having multiple loops in a single thread does not make sense unless you want to do manual priority-based scheduling among simultaneous events. Some more advanced systems provide such capability inside a single event loop using multiple event queues (such as the Grand Central Dispatch in macOS/iOS), but I don't think it's necessary for constrained platforms like RIOT. |
Ok, but because of this line, the thread that calls I can't block the main thread because of user constraints. So that there is two solutions : either using non-blocking methods in the main thread, or making the library work independently from the threads. |
The model of ndn-riot is that application runs in a thread and interact with the NDN protocol stack, which is another thread. That's why I'm trying to understand your use case here: is the main thread actively taking user input so it can't be blocked? Is it possible to apply the event-driven programming model for your application? (BTW: you can always use |
My use-case is that I try to implement a ROS2 Middleware using ndn.
|
After further investigation, an other solution would be to send the pid of the thread running the ndn_app with the inter-thread messages' payload. It would not change the API. But in my opinion it would be harder to change. |
Basically, what would be perfect would be an interface like in ndn-cxx : Face::processEvents. |
Can you resolve the conflict and re-push? |
I will, but not now, I need to check if this code is not outdated. Also, I want to wait for this RIOT PR to be merged before adding this feature. |
PR updated, and rebased ! The diff is dirty, but I'm more confident with this version. Indeed the old one was modifying the behavior of ndn_app_run while this one should keep the same behavior. I tested this PR as a RIOT pkg, ndn-ping is working fine. |
Using an other thread to execute
ndn_app_run
is not a good idea.A solution is to add a function
ndn_app_run_once
that does the same, but returns when there is no msg in the queue.