Comments (3)
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.
+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.
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)
- Impossibly large allocations fails but still allocates new memory pages
- Cloudflare Worker response bodies being mangled when using wee_alloc HOT 1
- Update outdated usage instruction regarding "extern crate"
- WASM Module HOT 1
- Possible allocator memory corruption? HOT 1
- Unbounded Memory Leak HOT 8
- Is this repo still maintained? HOT 8
- This repo needs to be archived and marked as deprecated HOT 4
- Binary size larger than advertized HOT 4
- free_cell_layout test fails on macOS HOT 1
- CI doesn't check configuration w/o size_classes
- CI should be running tests HOT 6
- Panicky wasm from Vec allocation HOT 2
- Release new version to crates.io HOT 1
- Add git tag for 0.4.3 HOT 1
- Storage at arbitrary address HOT 2
- wee_alloc leaks memory HOT 5
- Allow heap to start not at a page boundary HOT 2
- Shell scripts of repo not working due to wee_alloc compilation errors HOT 5
- Implement more efficient grow/shrink/realloc methods
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wee_alloc.