1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

optimistic_yield()

this introduces optimistic_yield() used for when standard library
methods are normally used in tight loops waiting for something to
happen, like available().
This commit is contained in:
Makuna
2015-07-13 13:47:13 -07:00
parent dece240830
commit d815c36753
7 changed files with 58 additions and 31 deletions

View File

@ -160,8 +160,16 @@ size_t TwoWire::write(const uint8_t *data, size_t quantity){
return quantity;
}
extern "C" void optimistic_yield();
int TwoWire::available(void){
return rxBufferLength - rxBufferIndex;
int result = rxBufferLength - rxBufferIndex;
if (!result) {
optimistic_yield();
}
return result;
}
int TwoWire::read(void){