Merge pull request #6418 from amq/poll-lowpowertimer

Add an option to use LowPowerTimer for poll
pull/6625/head
Cruz Monrreal 2018-04-12 18:37:22 -05:00 committed by GitHub
commit 339283b3b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -34,6 +34,11 @@
"force-non-copyable-error": { "force-non-copyable-error": {
"help": "Force compile time error when a NonCopyable object is copied", "help": "Force compile time error when a NonCopyable object is copied",
"value": false "value": false
},
"poll-use-lowpower-timer": {
"help": "Enable use of low power timer class for poll(). May cause missing events.",
"value": false
} }
}, },
"target_overrides": { "target_overrides": {

View File

@ -16,6 +16,7 @@
#include "mbed_poll.h" #include "mbed_poll.h"
#include "FileHandle.h" #include "FileHandle.h"
#include "Timer.h" #include "Timer.h"
#include "LowPowerTimer.h"
#ifdef MBED_CONF_RTOS_PRESENT #ifdef MBED_CONF_RTOS_PRESENT
#include "rtos/Thread.h" #include "rtos/Thread.h"
#endif #endif
@ -34,7 +35,11 @@ int poll(pollfh fhs[], unsigned nfhs, int timeout)
* interested in. In future, his spinning behaviour will be replaced with * interested in. In future, his spinning behaviour will be replaced with
* condition variables. * condition variables.
*/ */
#if MBED_CONF_PLATFORM_POLL_USE_LOWPOWER_TIMER
LowPowerTimer timer;
#else
Timer timer; Timer timer;
#endif
if (timeout > 0) { if (timeout > 0) {
timer.start(); timer.start();
} }