Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Shared state mechanism #12

Closed
Avokadoen opened this issue Jul 10, 2022 · 0 comments
Closed

Shared state mechanism #12

Avokadoen opened this issue Jul 10, 2022 · 0 comments
Assignees

Comments

@Avokadoen
Copy link
Owner

Avokadoen commented Jul 10, 2022

State that is not connected to the entity should be able to be expressed and shared across systems

Suggested API:

// writing to shared state should be allowed and thread safe 
// scheduler will avoid dispatching these in parallel
fn systemWithSharedStateMutate(a: A, window: Shared(*WindowHandle)) void {
    window_api.setCursor(.default);
    _ = a;
}

// read only shared state allow scheduler to do these in parallel!
fn systemWithSharedStateConst(a: A, color: Shared(CommonColors)) void {
    a.color = color.green;
}

var world = WorldBuilder().WithSystems(
    systemWithSharedStateMutate,
    systemWithSharedStateConst,
).WithSharedState(
    WindowHandle,
    CommonColors,
).init(allocator);

world.registerShared(WindowHandle, 123);

try world.dispatch(); // error.UndefinedSharedState 
@Avokadoen Avokadoen self-assigned this Aug 17, 2022
Avokadoen added a commit that referenced this issue Aug 21, 2022
allow systems to share central state and even mutate said state
This resolves issues #12
Avokadoen added a commit that referenced this issue Aug 21, 2022
allow systems to share central state and even mutate said state
This resolves issues #12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant