Ive been studying the Espruino source trying to understand its general architecture ... one of the things I seem to find is that it is a "busy poller". What I mean by this, is that it seems we have to regularly call "jsiLoop" when otherwise doing nothing else. This seems to call "jsiIdle" which appears to be where timer processing is being performed. One of the core things I was hoping to find was that there would be nothing going on while no events need processed. The ESP8266 is an extremely passive MCU meaning that one sets up event handlers and then gives control back to it as a supervisor. When something interesting happens such as a Serial character arriving, a timer firing, network traffic arriving, GPIO changing state ... that is when control is given back to us and we handle it from there. This is in contrast to what might be termed "busy polling" where we continually ask the environment "anything I need to do in this area?". By being passive and registering callbacks, the ESP8266 minimizes its power consumption ... effectively consuming as little as it can get away with and leveraging as much of the hardware as possible to detect events needing processed.
This "seems" to be in contrast to the Espruino architecture which appears to be more like the Arduino setup()/loop() structure of busy processing.
.... to be considered further.
© Espruino, powered by microcosm.
Report a problem