views:

37

answers:

0

Hi all, I am thinked to try to synchronizing two scripts (own firefox extension and greasemonkey's unsafeWindow.VARIABLE);

In extension:

window.ISS_NEED_SEND = 0;
window.SENDWHAT = 0;

while ... {
 if (window.ISS_NEED_SEND === 1) {
  writeFile(window.SENDWHAT); // safe synchronous call.
  window.ISS_NEED_SEND = 0;
}

In Greasemonkey:

if (iDoFile() === 1) {
    unsafeWindow.ISS_NEED_SEND = 1;
    unsafeWindow.SENDWHAT = fcnt;
    //... need to check ISS_NEED_SEND = 0, set by extension. It may take few seconds.
    // while { sleep; check; } is expected?
}

What is a best way to encapsulate the Greasemonkey's part into setTimeout check, is there any non-blocking way?