Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Static Generated Queries #54

Open
martindevans opened this issue Nov 29, 2023 · 2 comments
Open

Static Generated Queries #54

martindevans opened this issue Nov 29, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@martindevans
Copy link
Contributor

My game creates and destroys multiple world (running lots of mini-games in sequence). I've found that for the first World everything works fine, but for subsequent games any static queries will never be called.

Stepping through the generated source it seems as though the query is simply not finding any relevant entities.

Just to be clear, this is with queries generated like this:

[Query]
[None<PendingDestroy>]
private static void MySpecialQuery(in Thing whatever)
{
    // Do stuff
}

Note that it is a static query. Changing this to an instance method seems to fix the problem.

@genaray genaray added the bug Something isn't working label Dec 17, 2023
@genaray genaray moved this to Todo in Arch Roadmap Dec 17, 2023
@genaray
Copy link
Owner

genaray commented Dec 17, 2023

Is this sill a valid problem?
I think that was related to the PR you made a few weeks ago on archs core right?

@martindevans
Copy link
Contributor Author

#55 was merged, but that's only a partial fix.

If multiple worlds and multiple threads are in use then threads running the static query for one world might interfere with threads running the static query for another world by overwriting the cache and invalidating it while it's in use.

This could potentially be fixed by making the _{{queryMethod.MethodName}}_Initialized; and _{{queryMethod.MethodName}}_Query; methods [ThreadStatic]. But I haven't tested that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants