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

API Improvements / Code Maintenance #31

Closed
1 of 2 tasks
azriel91 opened this issue Sep 25, 2022 · 0 comments · Fixed by #32
Closed
1 of 2 tasks

API Improvements / Code Maintenance #31

azriel91 opened this issue Sep 25, 2022 · 0 comments · Fixed by #32

Comments

@azriel91
Copy link
Owner

azriel91 commented Sep 25, 2022

  • Change WebStorage to take in &Paths instead of &strs.
  • resources_type_state module should be resources::ts.

Provide types that will be inserted into Resources, instead of having a W<'op, Option<T>> and R<'op, Option<T>>
This requires &mut Resources, and while the graph is processing, we only have access to &Resources.

Rough idea:

use resman::Resource;

/// Something included inside a `Data` implementation.
#[derive(Debug)]
pub struct Insert<T> {
    tx: Sender<Box<dyn Resource>>,
}

impl<'borrow, T> Data<'borrow> for Insert<'borrow, T>
where
    T: Debug + Send + Sync + 'static,
{
    fn borrow(_resources: &'borrow Resources) -> Self {
        // no-op, as the ItemSpec will instantiate T.
    }
}

// T must be set before `Insert` is dropped?

impl<'borrow, T> Drop for Insert<'borrow, T>
where
    T: Debug + Send + Sync + 'static,
{
    fn drop() -> Self {
        self.tx.send(t);
    }
}

// Somewhere else in the framework.
// This still can't be inserted during a graph iteration.
let r = rx.receive().await;
resources.insert(t);
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

Successfully merging a pull request may close this issue.

1 participant