doc: Add and fix comments about never destroyed objects

This commit is contained in:
Hennadii Stepanov 2020-05-22 15:45:21 +03:00
parent 26c093a995
commit 90eb027204
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F
2 changed files with 4 additions and 2 deletions

View File

@ -22,8 +22,8 @@ BCLog::Logger& LogInstance()
* access the logger. When the shutdown sequence is fully audited and tested, * access the logger. When the shutdown sequence is fully audited and tested,
* explicit destruction of these objects can be implemented by changing this * explicit destruction of these objects can be implemented by changing this
* from a raw pointer to a std::unique_ptr. * from a raw pointer to a std::unique_ptr.
* Since the destructor is never called, the logger and all its members must * Since the ~Logger() destructor is never called, the Logger class and all
* have a trivial destructor. * its subclasses must have implicitly-defined destructors.
* *
* This method of initialization was originally introduced in * This method of initialization was originally introduced in
* ee3374234c60aba2cc4c5cd5cac1c0aefc2d817c. * ee3374234c60aba2cc4c5cd5cac1c0aefc2d817c.

View File

@ -95,6 +95,8 @@ struct LockData {
LockData& GetLockData() { LockData& GetLockData() {
// This approach guarantees that the object is not destroyed until after its last use. // This approach guarantees that the object is not destroyed until after its last use.
// The operating system automatically reclaims all the memory in a program's heap when that program exits. // The operating system automatically reclaims all the memory in a program's heap when that program exits.
// Since the ~LockData() destructor is never called, the LockData class and all
// its subclasses must have implicitly-defined destructors.
static LockData& lock_data = *new LockData(); static LockData& lock_data = *new LockData();
return lock_data; return lock_data;
} }