capnproto / capnproto-rust

Cap'n Proto for Rust
MIT License
2.04k stars 221 forks source link

Move to standard Allocator interface? #61

Open aneeshusa opened 8 years ago

aneeshusa commented 8 years ago

The Rust team yesterday accepted this RFC on a standard Allocator interface. It hasn't been implemented yet, but I was taking a look and it seems like it would cover the needs of the current Allocator trait in capnproto-rust - we can use the Layout struct to provide the same size + alignment properties that Word currently has.

When this becomes implemented in the stdlib, would you be interested in using it instead of/to back the current Allocator scheme in this crate? I'd be interested in working on a PR for this in the future.

dwrensha commented 8 years ago

Cool! Thanks for bringing this to my attention. It does sound like it would be a good idea to try to use the stdlib Allocator once it exists. Your contribution would be welcome. Let me know if you hit any trouble along the way.

burdges commented 8 years ago

I suppose this might simplify doing things like garbage collecting a message after making changes.

dwrensha commented 8 years ago

@burdges: As far as I understand, I don't think so. I imagine the stdlib allocator trait would be a replacement for capnp::message::Allocator, which handles allocation of entire segments. Within individual segments we carry out a form of arena allocation that needs to do a fair amount of capnproto-specific bookkeeping; I doubt we would be able to take advantage of a stdlib allocator trait there.