mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-10 04:22:05 +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:
@ -113,12 +113,22 @@ uint8_t WiFiUDP::beginMulticast(IPAddress interfaceAddr, IPAddress multicast, ui
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C" void optimistic_yield();
|
||||
|
||||
/* return number of bytes available in the current packet,
|
||||
will return zero if parsePacket hasn't been called yet */
|
||||
int WiFiUDP::available() {
|
||||
if (!_ctx)
|
||||
return 0;
|
||||
return static_cast<int>(_ctx->getSize());
|
||||
int result = 0;
|
||||
|
||||
if (_ctx) {
|
||||
result = static_cast<int>(_ctx->getSize());
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
optimistic_yield();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Release any resources being used by this WiFiUDP instance */
|
||||
|
Reference in New Issue
Block a user