Skip to content

Commit

Permalink
Merge pull request Abc-Arbitrage#13 from slumber/slumber/Abc-Arbitrag…
Browse files Browse the repository at this point in the history
…egh-12-event-poller

EventPoller: eliminate std::function in poll() arguments
  • Loading branch information
ybainier authored Sep 18, 2020
2 parents 4194602 + 465dcaf commit d62bfc6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 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 @@ -36,8 +38,13 @@ namespace Disruptor
, m_gatingSequence(gatingSequence)
{}

PollState poll(const std::function< bool(T&, std::int64_t, bool) >& eventHandler)
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 d62bfc6

Please sign in to comment.