[whatwg] WebWorkers and images

On 13/01/2011, at 16:27, Marijn Haverbeke wrote:

>> But if you could make it unreachable on the sending end then there would be no need to duplicate it, just to pass a reference to the worker, it would take about < 1 ns.
> 
> Yes, but the sender might have gotten this value from anywhere. All
> other code using the value will have to know that it is going to be
> invalidated, or it will use it and break. This complicates APIs and
> leads to subtle bugs in a way comparable to C's memory management.


Of course, you would have to write your code with this in mind. You wouldn't pass any object, you'd pass an object whose purpose is to be passed, special because it would be subject to some constraints, e.g. that once passed will become unreachable (and throw on access, or return null, or I don't what would be best). I don't think that would be a problem. You should code accordingly, or guard accesses with try/catch blocks. But the benefits would be huge, imo.
-- 
Jorge.

Received on Thursday, 13 January 2011 08:40:55 UTC