Infinite Queue
A queue processes tasks across six parallel slots, each rendering a horizontal bar that animates its width, then collapses and fades before removal. The demo appends div elements via d3.select and transitions, scheduling new tasks with setTimeout to sustain activity. A sentinel task that never invokes its callback keeps the queue running indefinitely, using d3.queue’s defer method. The code highlights the queue’s unbounded memory growth as results accumulate, a trade-off of this infinite-lifecycle pattern.
AI-generated descriptionA little demo of an infinitely long-living queue with 6 parallel slots for tasks. The sentinel task that never invokes the callback prevents the queue from ending, even if there are not any currently-active tasks.
There is a downside to this approach, however, which is that the queue’s internal task results array increases in length by one with each task, even though in this case the queue’s results are never triggered. Thus, be careful using this pattern if you really expect the queue to live indefinitely. Alternatively, it might be worth extending Queue’s minimal API to allow tasks to be processed without tracking their return value.