Skip to content

Commit

Permalink
EventPoller: static_assert the signature of eventHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
slumber authored and zhanghaokang committed Oct 19, 2023
1 parent 6dcc74e commit c9851a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Disruptor/EventPoller.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <functional>
#include <memory>

#include <boost/poly_collection/detail/is_invocable.hpp>

#include "Disruptor/FixedSequenceGroup.h"
#include "Disruptor/IDataProvider.h"
#include "Disruptor/ISequencer.h"
Expand Down Expand Up @@ -39,6 +41,10 @@ namespace Disruptor
template <class TEventHandler>
PollState poll(TEventHandler&& eventHandler)
{
using boost::poly_collection::detail::is_invocable_r;
static_assert(is_invocable_r<bool, TEventHandler, T&, std::int64_t, bool>::value,
"eventHandler should have the following signature: bool(T&, std::int64_t, bool)");

auto currentSequence = m_sequence->value();
auto nextSequence = currentSequence + 1;
auto availableSequence = m_sequencer->getHighestPublishedSequence(nextSequence, m_gatingSequence->value());
Expand Down

0 comments on commit c9851a5

Please sign in to comment.