Currently we have a weird mix:
TASK_DB - tokio task-local for Arc<Database>
Host::render_contexts - global DashMap for RenderContext
The DashMap exists because RPC callbacks come through TemplateHostImpl trait methods which receive a ContextId and look up the context.
But if callbacks always happen during the same .await as the render call (same tokio task), we could use task-local for the entire RenderContext instead of the DashMap lookup.
This would:
- Eliminate the DashMap
- Eliminate the separate
TASK_DB hack
- Simplify the architecture
TODO: Verify that roam RPC callbacks actually execute on the same tokio task as the caller. If yes, refactor to use a single task-local RenderContext.
Currently we have a weird mix:
TASK_DB- tokio task-local forArc<Database>Host::render_contexts- global DashMap forRenderContextThe DashMap exists because RPC callbacks come through
TemplateHostImpltrait methods which receive aContextIdand look up the context.But if callbacks always happen during the same
.awaitas the render call (same tokio task), we could use task-local for the entireRenderContextinstead of the DashMap lookup.This would:
TASK_DBhackTODO: Verify that roam RPC callbacks actually execute on the same tokio task as the caller. If yes, refactor to use a single task-local
RenderContext.