You are reading a single comment by @tve and its replies. Click here to read the full conversation.
  • Is the following code safe?

      JsVar *params[2];
      params[0] = jsvNewNull();
      params[1] = jsAccessPointArray;
      jsiQueueEvents(NULL, g_jsScanCallback, params, 2);
    
      jsvUnLock(jsAccessPointArray);
      jsvUnLock(g_jsScanCallback);
      jsvUnLock(params[0]);
      g_jsScanCallback = NULL;
      return;
    

    The reason I'm wondering is that this schedules a callback and then immediately proceeds to release locks (is there really a lock on the null object?). Is this safe because the callback is guaranteed to be completed before the next GC run? (Is GC not run automatically if an allocation fails?)

    NB: this snippet came from https://github.com/espruino/Espruino/blo­b/master/libs/network/esp8266/jswrap_esp­8266_network.c#L2008-L2016

About

Avatar for tve @tve started