Javascript semaphore / test-and-set / lock?
问题 Is there such a thing as an atomic test-and-set, semaphore, or lock in Javascript? I have javascript invoking async background processes via a custom protocol (the background process literally runs in a separate process, unrelated to the browser). I believe I'm running into a race condition; the background process returns between my test and my set, screwing things up on the javascript side. I need a test-and-set operation to make it a real semaphore. Here's the javascript code that attempts