aa at google.com
Tue Sep 30 09:46:39 PDT 2008
2008/9/30 Alexey Proskuryakov <ap at webkit.org>:
> I'm not sure it's so good in the case of dedicated workers either, as they
> can be used from other contexts via additional message ports. The close()
> method could just close the default port.
Sure, but in order for that to have happened, whoever created the
worker in the first place must have done it on purpose. The original
worker instance is anonymous. If the creator of that worker decides to
share it, that's fine, but it's more like cooperative sharing.
close() was added so that you could forcibly kill a worker. For
example, if you are searching a large set with many workers, you may
want to kill them once one finds a match.
The same could be achieved by just setting all the ports to null and
waiting for GC, but:
a) GC might not be for awhile, which is wasteful
b) It is hard to track where all the ports went
So I think it is useful to have a conceptual difference between
workers that are 'dedicated' and those that are 'shared'.
More information about the whatwg