Explain why the session lives in a per-instance slot

This commit is contained in:
Danny Kim
2026-09-26 01:54:31 +09:00
parent cb7330b8cb
commit 4ccd20299b
+4
View File
@@ -32,6 +32,10 @@ struct Session {
signer: Signer,
}
// The host creates one component instance per connection and calls into it
// on a single thread, so this slot holds exactly one connection's session and
// is not shared state between connections. A WASI component has no other place
// to keep state between exported calls.
thread_local! {
static SESSION: RefCell<Option<Session>> = const { RefCell::new(None) };
}