Skip to content

Commit

Permalink
iox-eclipse-iceoryx#831 Add test case for cxx::function in PeriodicTi…
Browse files Browse the repository at this point in the history
…mer tests

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
  • Loading branch information
mossmaurice committed Jun 27, 2022
1 parent a538d3a commit 8e323ff
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
11 changes: 11 additions & 0 deletions iceoryx_hoofs/test/moduletests/test_concurrent_periodic_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ TIMING_TEST_F(PeriodicTask_test, PeriodicTaskRunningWithStdFunction, Repeat(3),
EXPECT_THAT(PeriodicTaskTestType::callCounter, AllOf(Ge(MIN_RUNS), Le(MAX_RUNS)));
});

TIMING_TEST_F(PeriodicTask_test, PeriodicTaskRunningWithCxxFunction, Repeat(3), [&] {
{
concurrent::PeriodicTask<cxx::function<void()>> sut(
PeriodicTaskAutoStart, INTERVAL, "Test", PeriodicTaskTestType::increment);

std::this_thread::sleep_for(SLEEP_TIME);
}

EXPECT_THAT(PeriodicTaskTestType::callCounter, AllOf(Ge(MIN_RUNS), Le(MAX_RUNS)));
});

TIMING_TEST_F(PeriodicTask_test, PeriodicTaskWhichIsActiveAppliesNewIntervalAfterStart, Repeat(3), [&] {
auto start = std::chrono::steady_clock::now();
{
Expand Down
3 changes: 1 addition & 2 deletions iceoryx_posh/include/iceoryx_posh/internal/popo/wait_set.inl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ WaitSet<Capacity>::attachImpl(T& eventOrigin,
}
}

cxx::function<void(uint64_t)> invalidationCallback =
NotificationAttorney::getInvalidateTriggerMethod(eventOrigin);
cxx::function<void(uint64_t)> invalidationCallback = NotificationAttorney::getInvalidateTriggerMethod(eventOrigin);
auto index = m_indexRepository.pop();
if (!index)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_POSH_ROUDI_INTROSPECTION_PROCESS_INTROSPECTION_HPP
#define IOX_POSH_ROUDI_INTROSPECTION_PROCESS_INTROSPECTION_HPP

#include "iceoryx_hoofs/cxx/list.hpp"
#include "iceoryx_hoofs/cxx/function.hpp"
#include "iceoryx_hoofs/cxx/list.hpp"
#include "iceoryx_hoofs/internal/concurrent/periodic_task.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp"
Expand Down
15 changes: 7 additions & 8 deletions iceoryx_posh/include/iceoryx_posh/popo/listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,13 @@ class ListenerImpl
class Event_t;

void threadLoop() noexcept;
cxx::expected<uint32_t, ListenerError>
addEvent(void* const origin,
void* const userType,
const uint64_t eventType,
const uint64_t eventTypeHash,
internal::GenericCallbackRef_t callback,
internal::TranslationCallbackRef_t translationCallback,
const cxx::function<void(uint64_t)> invalidationCallback) noexcept;
cxx::expected<uint32_t, ListenerError> addEvent(void* const origin,
void* const userType,
const uint64_t eventType,
const uint64_t eventTypeHash,
internal::GenericCallbackRef_t callback,
internal::TranslationCallbackRef_t translationCallback,
const cxx::function<void(uint64_t)> invalidationCallback) noexcept;

void removeTrigger(const uint64_t index) noexcept;

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/include/iceoryx_posh/popo/trigger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_POSH_POPO_TRIGGER_HPP
#define IOX_POSH_POPO_TRIGGER_HPP

#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/cxx/function.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
#include "iceoryx_posh/popo/notification_callback.hpp"
#include "iceoryx_posh/popo/notification_info.hpp"
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/include/iceoryx_posh/popo/wait_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#define IOX_POSH_POPO_WAIT_SET_HPP

#include "iceoryx_hoofs/cxx/algorithm.hpp"
#include "iceoryx_hoofs/cxx/function.hpp"
#include "iceoryx_hoofs/cxx/function_ref.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/cxx/list.hpp"
#include "iceoryx_hoofs/cxx/function.hpp"
#include "iceoryx_hoofs/cxx/stack.hpp"
#include "iceoryx_hoofs/cxx/vector.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
Expand Down

0 comments on commit 8e323ff

Please sign in to comment.