I know one can either splice
an item out of an array, or delete it with delete
. The former approach can cause concurrency problems, e.g. if one thread is walking over the array while another has just shifted or spliced. delete
doesn't have this issue if forEach
is used on the array, since forEach
will walk over holes in the array.
However, the array can't keep growing forever and will necessitate sweeping, potentially causing the same issue as in the case of a splice. Sounds like I need locking, but I'd be amused if Javascript had any facilities for it. Any thoughts?