i have class transaction holds set of requests. every x seconds requests in current transaction set, , list of requests cleared.
is ok design class transaction in such way send requests in transaction during destruction, destructor?
this means allocate new transaction, add new requests long still alive, , once destructor called requests sent.
this way can guarantee that:
- all transactions sent (as long don't leak transaction objects).
- it impossible add changes transaction after sent.
is considered practice? or better use sendrequests method send requests , clear list?
a destructor has 1 purpose in c++ language. manage (so log, use helper object or function, etc) release of resources acquired in constructor per raii. other use going trouble sooner or later.
Comments
Post a Comment