Javascript semaphore / test-and-set / lock?

前端 未结 6 884
无人共我
无人共我 2020-12-13 23:09

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 b

6条回答
  •  温柔的废话
    2020-12-13 23:37

    Maybe you could implement a basic integer semaphore, just add the variable into the DOM and lock/unlock it and make sure your functions keep checking it, else timeout them =)

    If you are using a framework such as Mootools you could try to handle the flow of the app with events such as onComplete and so on.

提交回复
热议问题