Commit Detail
Commit 1a44749
Make ExternalMemoryTarget atomic-refcounted and const. `ExternalMemoryTarget` references are intended to be able to be held outside the isolate lock, but this means they must be thread-safe. That both means the refcounting must be atomic, and that all references must be const. KJ uses constness to enforce thread-safety; see: https://github.com/capnproto/capnproto/blob/v2/style-guide.md#constness Declaring this constness reveals that `ExternalMemoryTarget::reset()` is not thread-safe! Indeed: an isolate could be in the process of being torn down in one thread while another thread is destroying a memory adjustment that points at it, leading to problems. We'll need to fix this in a later commit.