SObjectizer
5.5
|
There are cases when a mchain is created at the beginning of a scope and the mchain must be automatically closed at the end of the scope. Something like:
The code shown above is not good and it can lead to errors in the case if some exception is raised between create_mchain
and close_drop_content
calls. It is better to use RAII idiom. Since v.5.5.16, there are auto_close_mchains
helpers which allows us to write as follows:
It is better but still it has some drawbacks: a user can forget to call auto_close_mchains
or can forget to store the value returned. Which is why a new helper class mchain_master_handle_t
was introduced in v.5.5.17. This class is intended to be used in the cases described above:
Note that auto_close_mchains
helpers are good tools for cases when it is necessary to work with already created mchains. For example: