Skip to content

Commit

Permalink
Disable Cancelable copy constructor (#3185)
Browse files Browse the repository at this point in the history
* Disable Cancelable copy constructor
  • Loading branch information
Rob Walker authored Oct 13, 2020
1 parent 9c938e2 commit 161de66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/lib/core/CHIPCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class Cancelable
return this;
}
~Cancelable() { Cancel(); }

Cancelable(const Cancelable &) = delete;
};

typedef void (*CallFn)(void *);
Expand Down Expand Up @@ -186,10 +188,8 @@ class CallbackDeque : public Cancelable
/**
* @brief dequeue, but don't cancel, all cas that match the by()
*/
Cancelable DequeueBy(bool (*by)(uint64_t, const Cancelable *), uint64_t p)
void DequeueBy(bool (*by)(uint64_t, const Cancelable *), uint64_t p, Cancelable & dequeued)
{
Cancelable dequeued;

for (Cancelable * ca = mNext; ca != this;)
{
Cancelable * next = ca->mNext;
Expand All @@ -200,7 +200,6 @@ class CallbackDeque : public Cancelable
}
ca = next;
}
return dequeued;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/system/SystemLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ Error Layer::SetClock_RealTime(uint64_t newCurTime)
void Layer::DispatchTimerCallbacks(const uint64_t kCurrentEpoch)
{
// dispatch TimerCallbacks
Cancelable ready = mTimerCallbacks.DequeueBy(TimerReady, kCurrentEpoch);
Cancelable ready;

mTimerCallbacks.DequeueBy(TimerReady, kCurrentEpoch, ready);

while (ready.mNext != &ready)
{
// one-shot
Expand Down

0 comments on commit 161de66

Please sign in to comment.