Skip to content

Unable to use AST across threads without making app state Sync + Send #991

@djgaven588

Description

@djgaven588

Hello! I have a game I am working on where recently I have been working towards using more threads and improving performance.

An issue I ran into while doing this, is that my game has 2 types of data:

  • Assets which can be moved between threads (including things with Rhai scripts)
  • GameState which is always on a single thread, and is passed to scripting as an argument

When trying to make it so I can execute Rhai scripts across threads (splitting my client and server), I found that in order to use things like AST on another thread I needed to enable the sync feature. However, this forces all types to require Sync + Send, which things such as my game state can't do, as some of these references are in fact tied to a specific thread.

Is there any way to get around this to somehow have AST Send + Sync, but not require all arguments to scripts to calling Rhai functions to also be Send + Sync?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions