How to prevent HTML5 Web Workers from locking up thus correctly responding to messages from parent

后端 未结 3 1183
梦谈多话
梦谈多话 2021-02-06 02:45

I\'m using web workers to do some CPU intensive work but have the requirement that the worker will respond to messages from the parent script while the worker is still processin

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 03:12

    Having the same problem I searched the web workers draft and found something in the Processing model section, steps from 9 to 12. As far as I have understood, a worker that starts processing a task will not process another one until the first is completed. So, if you don't care about stopping and resuming a task, nciagra's answer should give better performances than rescheduling each iteration of the task.

    Still investigating, though.

提交回复
热议问题