ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.04k stars 371 forks source link

Pool with RAII #890

Open alxrMironov opened 1 month ago

alxrMironov commented 1 month ago

Hello. The pool is pretty nice container in embedded systems. But there is an issue - it is incompatiable with RAII concept. (as far as i understand, i may be totally wrong).

It is nice to have a pool class, what generate some sort of pointer wrappers to objects, what can be deleted only by call the pool method. Or maybe even with integrated deleter.

jwellbelove commented 1 month ago

The problem is that the pool returns simple pointers or references to an object. It's possible that you could wrap the returned object in an etl::unique_ptr with a custom deleter. It may also be possible to add an additional member function that returns an etl::unique_ptr.