diwic / reffers-rs

Rust wrappers around references, boxes and Arcs.
68 stars 3 forks source link

Add Rc to RMBA #5

Closed vadixidav closed 6 years ago

vadixidav commented 7 years ago

I do not fully understand how RMBA currently works and if it is possible, but I believe it would be beneficial to add Rc to RMBA for situation where threading is not required. If it isn't possible, perhaps an enum can be added which is effectively the same as SlowRMBA, except with Rc, and then that can be used to verify the correct operation of RMBA instead of SlowRMBA. If you wish to do that, I can do it and submit a PR. What are your thoughts?

diwic commented 7 years ago

Hi! Due to the internals of RMBA, only four different values fit. They are already taken by &, &mut, Box and Arc. There is no room for a fifth one.

diwic commented 7 years ago

An interesting thought though, would be to make the entire thing generic so one could compose one's own out of the four provided...

vadixidav commented 7 years ago

Are the lower bits assumed to be aligned and used for encoding the type?

Either way, what are your thoughts on adding an enum with all the possible things (&, &mut, Box, Rc, Arc, and any others).

diwic commented 7 years ago

Are the lower bits assumed to be aligned and used for encoding the type?

Yes. The main purpose of the struct is saving memory without losing performance.

Either way, what are your thoughts on adding an enum with all the possible things (&, &mut, Box, Rc, Arc, and any others).

You mean adding a fifth variant to SlowRMBA? Maybe, but since you talked about performance being the main reason to prefer Rc over Arc, I'm not sure you'll gain much?

Also; right now SlowRMBA is Send, adding Rc would take that away.