Skip to content

Commit

Permalink
Fixed|libcore: Data races
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent a7c2bcf commit 66ba6a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doomsday/libs/core/src/data/bank.cpp
Expand Up @@ -78,10 +78,12 @@ class Cache : public Lockable
int itemCount() const { return _items.size(); }

virtual void add(ItemType &data) {
DE_GUARD(this);
_items.insert(&data);
}

virtual void remove(ItemType &data) {
DE_GUARD(this);
_items.remove(&data);
}

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/src/net/beacon.cpp
Expand Up @@ -92,7 +92,7 @@ DE_PIMPL(Beacon)
}

static void readIncoming(iAny *, iDatagram *sock)
{
{
Loop::mainCall([sock]() {
LOG_AS("Beacon");
auto *d = reinterpret_cast<Beacon::Impl *>(userData_Object(sock));
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libs/core/src/widgets/animation.cpp
Expand Up @@ -68,9 +68,9 @@ using AnimationFlags = Flags;

/// Thread-safe current time for animations.
struct AnimationTime : DE_OBSERVES(Clock, TimeChange) {
double now;
std::atomic<double> now;
void timeChanged(Clock const &clock) override {
now = clock.time().highPerformanceTime();
now.store(clock.time().highPerformanceTime());
}
};
static AnimationTime theTime;
Expand Down Expand Up @@ -276,7 +276,7 @@ float Animation::value() const
{
return d->target;
}
return d->valueAt(theTime.now);
return d->valueAt(theTime.now.load());
}

bool Animation::done() const
Expand Down

0 comments on commit 66ba6a1

Please sign in to comment.