AshampooSystems / boden

Purely native C++ cross-platform GUI framework for Android and iOS development. https://www.boden.io
Other
1.67k stars 96 forks source link

Smart Pointers [Question] #2

Closed webfolderio closed 5 years ago

webfolderio commented 5 years ago

Hi,

Why did you decide to use bdn::newObject instead of smart pointers?

Thanks

haukeduden commented 5 years ago

The smart pointer system is actually still a topic of discussion in the Boden team as well. It has a couple of nice properties, like the fine grained control bdn::P gives us over the time when an object is actually destructed. For example, these pointers provide an easy way to ensure that destruction of our View objects happens only on the main thread, no matter which thread released the last reference.

But on the other hand, not using the standard constructs is definitely a cost. We are happy for your feedback on this issue.

Note that we also think about the idea of transforming P and making it a specialization of std::shared_ptr for objects derived from bdn::Base. That would give us the best of both worlds. Feel free to let us know what you think.

gitoby commented 5 years ago

After internal discussions and further community feedback on HN and Reddit we've revised that decision. Boden now largely uses idiomatic C++ including std::shared_ptr instead of bdn::P. See commit dd2742bdb82f5c934b8fe3bf016b4a5ab0a4a61f for reference.