Skip to content
Commit Detail

Commit 1a44749

Author
Kenton Varda <kenton@cloudflare.com> 2025-04-11 09:48:52 -0500
Parents
4596b48
Tree
3935a2d
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.

Files changed