dispatcher::discard becomes dispatcher::clear

This commit is contained in:
Michele Caini
2019-12-21 00:35:30 +01:00
parent f0dc882ae9
commit 56e7dd0de0
3 changed files with 4 additions and 4 deletions

View File

@@ -107,7 +107,7 @@ delegate(42);
```
Where the function type of the delegate is `void(int)` as above. It goes without
saying that the extra arguments are silently discarded internally.<br/>v
saying that the extra arguments are silently discarded internally.<br/>
This is a nice-to-have feature in a lot of cases, as an example when the
`delegate` class is used as a building block of a signal-slot system.

View File

@@ -187,7 +187,7 @@ public:
* @tparam Event Type of events to discard.
*/
template<typename... Event>
void discard() {
void clear() {
if constexpr(sizeof...(Event) == 0) {
std::for_each(pools.begin(), pools.end(), [](auto &&cpool) {
cpool->clear();

View File

@@ -42,11 +42,11 @@ TEST(Dispatcher, Functionalities) {
ASSERT_EQ(receiver.cnt, 3);
dispatcher.enqueue<an_event>();
dispatcher.discard<an_event>();
dispatcher.clear<an_event>();
dispatcher.update();
dispatcher.enqueue<an_event>();
dispatcher.discard();
dispatcher.clear();
dispatcher.update();
ASSERT_EQ(receiver.cnt, 3);