Update AsyncEventBus::consume to be more "logic"

This commit is contained in:
Dawid Drozd 2019-06-13 19:38:05 +02:00
parent 6c9ba0640c
commit 66d408926f
2 changed files with 3 additions and 9 deletions

View File

@ -4,6 +4,7 @@
#include <cassert> #include <cassert>
#include <deque> #include <deque>
#include <functional> #include <functional>
#include <limits>
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
@ -177,11 +178,11 @@ public:
/** /**
* Process queued events. This should be called always on same thread. * Process queued events. This should be called always on same thread.
* @param max maximum count of events to consume, if 0 then all available events will be consumed. * @param max maximum count of events to consume.
* If max is higher than available events then only available events will be consumed. * If max is higher than available events then only available events will be consumed.
* @return number of consumed events * @return number of consumed events
*/ */
int consume(int max = 0); int consume(int max = std::numeric_limits<int>::max());
std::size_t getQueueEventCount() const std::size_t getQueueEventCount() const
{ {

View File

@ -1,7 +1,5 @@
#include <eventbus/AsyncEventBus.h> #include <eventbus/AsyncEventBus.h>
#include <limits>
namespace Dexode namespace Dexode
{ {
@ -20,11 +18,6 @@ std::size_t AsyncEventBus::processCommandsAndGetQueuedEventsCount()
int AsyncEventBus::consume(int max) int AsyncEventBus::consume(int max)
{ {
if(max == 0)
{
max = std::numeric_limits<int>::max();
}
int consumed = 0; int consumed = 0;
std::function<void()> eventCommand; std::function<void()> eventCommand;