Giter Club home page Giter Club logo

Comments (3)

fitzgen avatar fitzgen commented on June 19, 2024

So you're thinking that we make each imp module export a Backend trait (or whatever name) that provides the current "duck typed" module interface, but has access to &self?

trait Backend {
    fn alloc_pages(&self, pages: Pages) -> Result<NonNull<Opaque>, AllocErr>;
}

Then, you would generalize the static array backend to allow providing a slice of memory at runtime?

This would require threading T: Backend type parameters and members through everything, but that isn't too terrible, just write-once boilerplate.

The hard part would be if we tried to put Exclusive<T> as an associated type within the Backend trait. That would require generic associated types, unless I'm missing some trick. I guess we could leave that out of the trait, as it is now.

I'm a soft +1 to this proposal in general. What do other team folks think? cc @pepyakin @DrGoldfire @ZackPierce

from wee_alloc.

DrGoldfire avatar DrGoldfire commented on June 19, 2024

+1 from me. I like the idea of serving the general-purpose no_std allocator case better; I know there's demand in the embedded sphere for this sort of thing. As long as we're not regressing the wasm target, which it doesn't sound to me as if this would do.

from wee_alloc.

ZackPierce avatar ZackPierce commented on June 19, 2024

I generally like the idea of transforming the backend implementations to traits, though there are a few design details to work out. Off the top of my head,

  • Should fn alloc_pages have access to &self or &mut self? [My guess: &mut self]
  • How does this interact with the Exclusive code (as @fitzgen pointed out)?
  • Does the ability to select backend by trait rather than compile-time-configuration-flags mean we should adjust our feature flagging strategy?

from wee_alloc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.