javascript - Thread-safe array deletions -


i know 1 can either splice item out of array, or delete delete. former approach can cause concurrency problems, e.g. if 1 thread walking on array while has shifted or spliced. delete doesn't have issue if foreach used on array, since foreach walk on holes in array.

however, array can't keep growing forever , necessitate sweeping, potentially causing same issue in case of splice. sounds need locking, i'd amused if javascript had facilities it. thoughts?

no, can't have concurrency problem javascript isn't multithreaded. if use webworkers won't have problems no data shared (workers communicate passing messages). in node.js script isn't multi-threaded.

so use splice, there no need lock array.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -