Skip to content

Commit

Permalink
libcore: Improved Observers for multithreading
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 1cbdc4d commit bac9874
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions doomsday/libs/core/include/de/data/observers.h
Expand Up @@ -378,14 +378,11 @@ class Observers : public Lockable, public IAudience
virtual ~Observers()
{
_disassociateAllMembers();
DE_GUARD(this);
}

void clear()
{
DE_GUARD(this);
_disassociateAllMembers();
_members.clear();
}

Observers<Type> &operator=(Observers<Type> const &other)
Expand Down Expand Up @@ -522,8 +519,14 @@ class Observers : public Lockable, public IAudience
private:
void _disassociateAllMembers()
{
for (Type *observer : _members)
for (;;)
{
Type *observer;
{
DE_GUARD(this);
if (_members.isEmpty()) break;
observer = _members.take();
}
observer->removeMemberOf(*this);
}
}
Expand Down

0 comments on commit bac9874

Please sign in to comment.