andywer / andywer/threads.js

Make workers pull from your own queue

未关闭
#440 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
3.5k
派生
173
PR 合并指标
30 天内没有已合并 PR

描述

I know threadsjs has a queue method available on it's `Pool` class, but I want to create my own queue, in particular I'm writing a persistent queue.

I would like the worker threads to pull from the queue when they are ready/idle for the next task. And this pulling mechanism needs to be blocking to avoid busy-looping on the workers. That is they should just be awaiting on a promise that only resolves when a task is available for dispatch.

What is the right way to do this? Should I be extending the `Pool` class, or can I make the workers directly pull from some sort of shared queue data structure system?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。