21 #ifndef INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_POLICIES_FIFO_IMPL_H_ 22 #define INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_POLICIES_FIFO_IMPL_H_ 25 #include "../helpers/tuple.h" 26 #include "../helpers/scoped_unlock.h" 30 namespace combiner_policies
33 template<
typename... IOs>
36 if (max_queue_size == 0)
throw std::invalid_argument(
"max_queue_size must not be zero");
38 [
this, max_queue_size](
auto I)
40 std::get<I>(this->in_).set_capacity(max_queue_size);
45 template<
typename... IOs>
46 template<std::
size_t N>
47 void Fifo<IOs...>::add(std::unique_lock<std::mutex>& lock,
const std::tuple_element_t<N, IncomingTuples>& item)
49 std::get<N>(in_).push_back(item);
50 while (has_complete_tuple())
54 [
this, &tmp, &lock](
auto... Is)
57 this->emit(std::tuple_cat(*std::get<Is>(tmp)...));
63 template<
typename... IOs>
68 [
this, &result](
auto I)
70 if (std::get<I>(this->in_).empty()) result =
false;
77 template<
typename... IOs>
84 std::get<I>(tmp) = std::get<I>(this->in_).front();
85 std::get<I>(this->in_).pop_front();
91 template<
typename... IOs>
97 std::get<I>(this->in_).clear();
void add(std::unique_lock< std::mutex > &, const std::tuple_element_t< N, IncomingTuples > &)
Input function.
void reset() noexcept override
Reset internal state.
bool has_complete_tuple() noexcept
First-In-First-Out policy.
Fifo(std::size_t max_queue_size=1)
Constructor.
std::tuple< boost::optional< helpers::io_tuple_t< IOs > >... > MaybeOutgoingTuples
Tuple of outgoing tuple candidates.
void for_each_apply(Function f)
ScopedUnlock< BasicLockable > with_scoped_unlock(BasicLockable &lockable)
MaybeOutgoingTuples assemble_output() noexcept
auto index_apply(Function f)