Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

RFC: Refactor context #125

Closed
msiglreith opened this issue Oct 26, 2016 · 3 comments
Closed

RFC: Refactor context #125

msiglreith opened this issue Oct 26, 2016 · 3 comments
Assignees
Labels
diff: normal Achievable by an reasonable experienced developer. If new to Amethyst, may need some guidance. pri: important Something other teams are relying on, or a low-level, critical piece of functionality.
Projects

Comments

@msiglreith
Copy link
Contributor

Motivation

The context struct is a large struct containing different subsystems (

/// Contains all engine resources which must be shared by multiple parties, in particular `Renderer` and `Broadcaster`.
/// An `Arc<Mutex<Context>>` is passed to every `Processor` run by the engine and a `&mut Context` is passed to every `State`
/// method.
pub struct Context {
// pub video_context: VideoContext,
pub renderer: Renderer,
pub asset_manager: AssetManager,
pub input_handler: InputHandler,
pub broadcaster: Broadcaster,
pub delta_time: Duration,
pub fixed_step: Duration,
pub last_fixed_update: Instant,
}
), which is passed as Arc<..> to the different processor requiring to lock the whole context.

Proposal

Split the context into the separated subsystems + a new context (with delta_time, timestep, ...).
The subsystems are added as resources to the world, allowing a more fine-granual locking and removes the need of a global object passed around trough the whole engine.

Open questions

How does this influence the entity-component system in terms of scheduling?
Will we only have a single world in the future, if not how should the resources be handled?

@Aceeri
Copy link
Member

Aceeri commented Oct 27, 2016

I'm pretty sure resources in specs behave exactly the same as components, splitting it up into subsystems just means less blocking between systems to get access to the context (when they might not use it).

I think it is safe to assume we will only have one world, I'm not sure what benefits you would get by having multiple.

@nchashch nchashch added diff: normal Achievable by an reasonable experienced developer. If new to Amethyst, may need some guidance. pri: important Something other teams are relying on, or a low-level, critical piece of functionality. type: RFC labels Oct 29, 2016
@Aceeri
Copy link
Member

Aceeri commented Nov 6, 2016

To add to this, I'm thinking maybe we should move the context out of a sub-crate and into the core library of amethyst (similar to the ecs processors and such), since it is highly interconnected with the other sub-crates. Thoughts?

@msiglreith
Copy link
Contributor Author

Seems to be fixed by #133.

@ebkalderon ebkalderon added this to Done in Engine Feb 3, 2017
@ebkalderon ebkalderon moved this from Done to Shipped in Engine Feb 7, 2017
@ebkalderon ebkalderon moved this from Shipped to Done in Engine Feb 7, 2017
@ebkalderon ebkalderon moved this from Done to Shipped in Engine Feb 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
diff: normal Achievable by an reasonable experienced developer. If new to Amethyst, may need some guidance. pri: important Something other teams are relying on, or a low-level, critical piece of functionality.
Projects
No open projects
Engine
  
Shipped
Development

No branches or pull requests

4 participants