Skip to content

Explore using task-local for RenderContext instead of DashMap #209

@fasterthanlime

Description

@fasterthanlime

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:

  1. Eliminate the DashMap
  2. Eliminate the separate TASK_DB hack
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions