简体   繁体   English

Web Worker postMessage({})何时返回调用者

[英]When does Web Worker postMessage({}) return to caller

I have a recollection of reading that a postMessage request will not return until the onmessage event has been delivered to the recipient. 我有种回忆,那就是在onmessage事件传递给接收者之前,postMessage请求将不会返回。

Having said that, I can't seem to find any reference on the web at the mo and docs such as: - https://html.spec.whatwg.org/multipage/workers.html talk of message "queues" which make me think that messages can be stacked/queued up for processing. 话虽如此,我似乎在网上找不到其他参考资料,例如:-https: //html.spec.whatwg.org/multipage/workers.html关于消息“队列”的讨论我认为可以将消息堆叠/排队进行处理。

Does someone here have a reference pointer for the prescribed behaviour? 这里有人为规定的行为提供参考指针吗?

Can a web-page and worker get into a deadlock by simply trying to send messages to each other at the same time? 网页和工作人员是否可以通过尝试同时相互发送消息而陷入僵局?

It returns pretty much immediately. 它立即返回。 Messages are queued by postMessage() and then copied/transferred "behind the scenes" and delivered to workers asynchronously. 消息由postMessage()排队,然后“在幕后”复制/传输,并异步传递给工作人员。 Same for the other way around. 反之亦然。 Deadlock should not be possible, unless you halt all processing until you've seen a certain message, of course. 死锁应该是不可能的,除非您停止所有处理,直到看到特定消息为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM