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:
@ -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){
|
||||
|
Reference in New Issue
Block a user