[+] ADestructionWatcher::ADestructionWatcher(ADestructionWatcher &&move);
[+] ADestructionWatcher::ADestructionWatcher(const ADestructionWatcher ©); [+] ADestructionWatcher::ADestructionWatcher &operator =(ADestructionWatcher &&move); [+] ADestructionWatcher::ADestructionWatcher &operator =(const ADestructionWatcher ©);
This commit is contained in:
parent
1e53972a2a
commit
c3cb380eca
@ -42,6 +42,12 @@ namespace Aurora::Utility
|
||||
inline bool IsObservedAlive();
|
||||
inline bool IsObservedDead();
|
||||
|
||||
inline ADestructionWatcher(ADestructionWatcher &&move);
|
||||
inline ADestructionWatcher(const ADestructionWatcher ©);
|
||||
|
||||
inline ADestructionWatcher &operator =(ADestructionWatcher &&move);
|
||||
inline ADestructionWatcher &operator =(const ADestructionWatcher ©);
|
||||
|
||||
protected:
|
||||
// Note that since the parent object is in the midst of destruction; you should not be manually calling the destroy operations of it or its' children.
|
||||
// C++ construction and the inverse destruction order are well defined.
|
||||
@ -198,6 +204,52 @@ namespace Aurora::Utility
|
||||
this->OnSelfDTOR();
|
||||
}
|
||||
|
||||
ADestructionWatcher::ADestructionWatcher(ADestructionWatcher &&move)
|
||||
{
|
||||
AU_LOCK_GUARD(move.selfLock);
|
||||
|
||||
if (auto pParent = AuExchange(move.pParent, nullptr))
|
||||
{
|
||||
pParent->RemoveWatcher(&move);
|
||||
this->Observe(pParent);
|
||||
}
|
||||
}
|
||||
|
||||
ADestructionWatcher::ADestructionWatcher(const ADestructionWatcher ©)
|
||||
{
|
||||
AU_LOCK_GUARD(copy.selfLock);
|
||||
|
||||
if (auto &pParent = copy.pParent)
|
||||
{
|
||||
this->Observe(pParent);
|
||||
}
|
||||
}
|
||||
|
||||
ADestructionWatcher &ADestructionWatcher::operator =(ADestructionWatcher &&move)
|
||||
{
|
||||
AU_LOCK_GUARD(move.selfLock);
|
||||
|
||||
if (auto pParent = AuExchange(move.pParent, nullptr))
|
||||
{
|
||||
pParent->RemoveWatcher(&move);
|
||||
this->Observe(pParent);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ADestructionWatcher &ADestructionWatcher::operator =(const ADestructionWatcher ©)
|
||||
{
|
||||
AU_LOCK_GUARD(copy.selfLock);
|
||||
|
||||
if (auto &pParent = copy.pParent)
|
||||
{
|
||||
this->Observe(pParent);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ADestructionWatcher::Observe(DestructionWatch *pWatch)
|
||||
{
|
||||
AU_LOCK_GUARD(pWatch->mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user