mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 06:49:38 -04:00
kernel: avoid potential duplicate object in shared library/binary
Fixes warning and potential bug whereby init_flag may exist in both libbitcoinkernel as well as a downstream user, as opposed to being shared as intended. src/support/lockedpool.h:224:31: warning: 'init_flag' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage [-Wunique-object-duplication]
This commit is contained in:
parent
5ca103aac6
commit
763c9ddfab
2 changed files with 8 additions and 6 deletions
|
@ -400,3 +400,10 @@ void LockedPoolManager::CreateInstance()
|
|||
static LockedPoolManager instance(std::move(allocator));
|
||||
LockedPoolManager::_instance = &instance;
|
||||
}
|
||||
|
||||
LockedPoolManager& LockedPoolManager::Instance()
|
||||
{
|
||||
static std::once_flag init_flag;
|
||||
std::call_once(init_flag, LockedPoolManager::CreateInstance);
|
||||
return *LockedPoolManager::_instance;
|
||||
}
|
||||
|
|
|
@ -219,12 +219,7 @@ class LockedPoolManager : public LockedPool
|
|||
{
|
||||
public:
|
||||
/** Return the current instance, or create it once */
|
||||
static LockedPoolManager& Instance()
|
||||
{
|
||||
static std::once_flag init_flag;
|
||||
std::call_once(init_flag, LockedPoolManager::CreateInstance);
|
||||
return *LockedPoolManager::_instance;
|
||||
}
|
||||
static LockedPoolManager& Instance();
|
||||
|
||||
private:
|
||||
explicit LockedPoolManager(std::unique_ptr<LockedPageAllocator> allocator);
|
||||
|
|
Loading…
Add table
Reference in a new issue