Skip to content

Add an option to use LowPowerTimer for poll #6418

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

Merged
merged 2 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions platform/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"force-non-copyable-error": {
"help": "Force compile time error when a NonCopyable object is copied",
"value": false
},

"poll-use-lowpower-timer": {
Copy link
Contributor

@0xc0170 0xc0170 Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

events have something similar:

        "use-lowpower-timer-ticker": {
            "help": "Enable use of low power timer and ticker classes. May reduce the accuracy of the event queue.",
            "value": 0
        }

these 2 are similar in functionality, should be aligned

however, lets first answer more important questions here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to align it as much as possible

Why not use-lowpower-timer? This would imply that the whole platform uses LowPowerTimer

Why not poll-use-lowpower-ticker-timer? There is no ticker here, unlike in events

"help": "Enable use of low power timer class for poll(). May cause missing events.",
"value": false
}
},
"target_overrides": {
Expand Down
5 changes: 5 additions & 0 deletions platform/mbed_poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mbed_poll.h"
#include "FileHandle.h"
#include "Timer.h"
#include "LowPowerTimer.h"
#ifdef MBED_CONF_RTOS_PRESENT
#include "rtos/Thread.h"
#endif
Expand All @@ -34,7 +35,11 @@ int poll(pollfh fhs[], unsigned nfhs, int timeout)
* interested in. In future, his spinning behaviour will be replaced with
* condition variables.
*/
#if MBED_CONF_PLATFORM_POLL_USE_LOWPOWER_TIMER
LowPowerTimer timer;
#else
Timer timer;
#endif
if (timeout > 0) {
timer.start();
}
Expand Down