Bug 1823391 Comment 9 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

My understanding is that (as bug 1828130 shows) we definitely should not try to create `RefPtr` to `this` in the constructor as we initialize the refcount with 0 and a `RefPtr` that is adding and releasing while in the constructor will end up freeing `this` and whoever wanted to allocate the object will get a pointer to already freed memory.

So we probably want to have an `Init`function that does all the heavy lifting like adding a `StrongWorkerRef` and such. Once we have that we can again have a meaningful lambda to react on worker shutdown. With that regard I was thinking if we also should do something like [aborting pending executions if any](https://searchfox.org/mozilla-central/rev/c82691a556c74c37e7f4d0f18f2cabedb004272c/dom/workers/ScriptLoader.cpp#852,855) befopre we `TryShutdown`.
My understanding is that (as bug 1828130 shows) we definitely should not try to create `RefPtr` to `this` in the constructor as we initialize the refcount with 0 and a `RefPtr` that is adding and releasing while in the constructor will end up freeing `this` and whoever wanted to allocate the object will get a pointer to already freed memory.

So we probably want to have an `Init`function that does all the heavy lifting like adding a `StrongWorkerRef` and such. Once we have that we can again have a meaningful lambda to react on worker shutdown. With that regard I was thinking if we also should do something like [aborting pending executions if any](https://searchfox.org/mozilla-central/rev/c82691a556c74c37e7f4d0f18f2cabedb004272c/dom/workers/ScriptLoader.cpp#852,855) before we `TryShutdown`.
We probably want to have an `Init`function that does all the heavy lifting like adding a `StrongWorkerRef` and such. Once we have that we can again have a meaningful lambda to react on worker shutdown. With that regard I was thinking if we also should do something like [aborting pending executions if any](https://searchfox.org/mozilla-central/rev/c82691a556c74c37e7f4d0f18f2cabedb004272c/dom/workers/ScriptLoader.cpp#852,855) before we `TryShutdown`.

Back to Bug 1823391 Comment 9