Skip to content

Commit

Permalink
Fixed warnings under /W4 in MSVC and -Wall -Wextra in GCC. Raised war…
Browse files Browse the repository at this point in the history
…ning level in unittests to highest.
  • Loading branch information
wqking committed May 28, 2019
1 parent 2f2b506 commit 6ad5c1f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 42 deletions.
2 changes: 1 addition & 1 deletion include/eventpp/eventpolicies.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct SingleThreading
value = desired;
}

T load(std::memory_order order = std::memory_order_seq_cst) const noexcept
T load(std::memory_order /*order*/ = std::memory_order_seq_cst) const noexcept
{
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion include/eventpp/eventqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class EventQueueBase <
}

template <typename F>
bool doInvokeFuncWithQueuedEventHelper(F && func, const typename super::Event & e, Args ...args) const
bool doInvokeFuncWithQueuedEventHelper(F && func, const typename super::Event & /*e*/, Args ...args) const
{
return func(std::forward<Args>(args)...);
}
Expand Down
2 changes: 1 addition & 1 deletion include/eventpp/internal/eventpolicies_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct ForEachMixins <Root, MixinList<>, Func>
using Type = Root;

template <typename ...A>
static bool forEach(A && ...args) {
static bool forEach(A && .../*args*/) {
return true;
}
};
Expand Down
12 changes: 6 additions & 6 deletions include/eventpp/utilities/eventutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool hasListener(
dispatcher.forEachIf(
event,
[&found, &listener](
const typename DispatcherType::Handle & handle,
const typename DispatcherType::Handle & /*handle*/,
const typename DispatcherType::Callback & item
) -> bool {
if(item == listener) {
Expand All @@ -111,8 +111,8 @@ bool hasAnyListener(
dispatcher.forEachIf(
event,
[&found](
const typename DispatcherType::Handle & handle,
const typename DispatcherType::Callback & item
const typename DispatcherType::Handle & /*handle*/,
const typename DispatcherType::Callback & /*item*/
) -> bool {
found = true;
return false;
Expand All @@ -131,7 +131,7 @@ bool hasListener(
bool found = false;
callbackList.forEachIf(
[&found, &callback](
const typename CallbackListType::Handle & handle,
const typename CallbackListType::Handle & /*handle*/,
const typename CallbackListType::Callback & item
) -> bool {
if(item == callback) {
Expand All @@ -155,8 +155,8 @@ bool hasAnyListener(
bool found = false;
callbackList.forEachIf(
[&found](
const typename CallbackListType::Handle & handle,
const typename CallbackListType::Callback & item
const typename CallbackListType::Handle & /*handle*/,
const typename CallbackListType::Callback & /*item*/
) -> bool {
found = true;
return false;
Expand Down
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ set(THIRDPARTY_PATH ../../thirdparty)

include_directories(../include)

if(MSVC)
add_definitions(/W4)
else()
add_definitions(-Wall -Wextra)
endif()

add_subdirectory(unittest)
add_subdirectory(benchmark)

67 changes: 35 additions & 32 deletions tests/benchmark/b3_b5_eventqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,47 +154,50 @@ void doMultiThreadingExecuteEventQueue(

} //unnamed namespace

// To avoid warning "typedef locally defined but not used" in GCC,
// let's move the policies outside of the test case functions

struct B3PoliciesMultiThreading {
using Threading = eventpp::MultipleThreading;
};
struct B3PoliciesSingleThreading {
using Threading = eventpp::SingleThreading;
};

TEST_CASE("b3, EventQueue, one thread")
{
struct PoliciesMultiThreading {
using Threading = eventpp::MultipleThreading;
};
struct PoliciesSingleThreading {
using Threading = eventpp::SingleThreading;
};

doExecuteEventQueue<PoliciesMultiThreading>("Multi threading", 100, 1000 * 100, 100);
doExecuteEventQueue<PoliciesMultiThreading>("Multi threading", 1000, 1000 * 100, 100);
doExecuteEventQueue<PoliciesMultiThreading>("Multi threading", 1000, 1000 * 100, 1000);

doExecuteEventQueue<PoliciesSingleThreading>("Single threading", 100, 1000 * 100, 100);
doExecuteEventQueue<PoliciesSingleThreading>("Single threading", 1000, 1000 * 100, 100);
doExecuteEventQueue<PoliciesSingleThreading>("Single threading", 1000, 1000 * 100, 1000);
doExecuteEventQueue<B3PoliciesMultiThreading>("Multi threading", 100, 1000 * 100, 100);
doExecuteEventQueue<B3PoliciesMultiThreading>("Multi threading", 1000, 1000 * 100, 100);
doExecuteEventQueue<B3PoliciesMultiThreading>("Multi threading", 1000, 1000 * 100, 1000);

doExecuteEventQueue<B3PoliciesSingleThreading>("Single threading", 100, 1000 * 100, 100);
doExecuteEventQueue<B3PoliciesSingleThreading>("Single threading", 1000, 1000 * 100, 100);
doExecuteEventQueue<B3PoliciesSingleThreading>("Single threading", 1000, 1000 * 100, 1000);
}

struct B4PoliciesMultiThreading {
using Threading = eventpp::GeneralThreading<std::mutex>;
};

TEST_CASE("b4, EventQueue, multi threads, mutex")
{
struct PoliciesMultiThreading {
using Threading = eventpp::GeneralThreading<std::mutex>;
};

doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Mutex", 1, 1, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Mutex", 1, 3, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Mutex", 2, 2, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Mutex", 4, 4, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Mutex", 16, 16, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B4PoliciesMultiThreading>("Mutex", 1, 1, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B4PoliciesMultiThreading>("Mutex", 1, 3, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B4PoliciesMultiThreading>("Mutex", 2, 2, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B4PoliciesMultiThreading>("Mutex", 4, 4, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B4PoliciesMultiThreading>("Mutex", 16, 16, 1000 * 1000 * 10, 100);
}

struct B5PoliciesMultiThreading {
using Threading = eventpp::GeneralThreading<eventpp::SpinLock>;
};

TEST_CASE("b5, EventQueue, multi threads, spinlock")
{
struct PoliciesMultiThreading {
using Threading = eventpp::GeneralThreading<eventpp::SpinLock>;
};

doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Spinlock", 1, 1, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Spinlock", 1, 3, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Spinlock", 2, 2, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Spinlock", 4, 4, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<PoliciesMultiThreading>("Spinlock", 16, 16, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B5PoliciesMultiThreading>("Spinlock", 1, 1, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B5PoliciesMultiThreading>("Spinlock", 1, 3, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B5PoliciesMultiThreading>("Spinlock", 2, 2, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B5PoliciesMultiThreading>("Spinlock", 4, 4, 1000 * 1000 * 10, 100);
doMultiThreadingExecuteEventQueue<B5PoliciesMultiThreading>("Spinlock", 16, 16, 1000 * 1000 * 10, 100);
}

2 changes: 1 addition & 1 deletion tests/unittest/tutorial_eventdispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TEST_CASE("EventDispatcher tutorial 4, event canceling")
std::cout << "Got event 3" << std::endl;
e.canceled = true;
});
dispatcher.appendListener(3, [](const Tutor4MyEvent & e) {
dispatcher.appendListener(3, [](const Tutor4MyEvent & /*e*/) {
std::cout << "Should not get this event 3" << std::endl;
});

Expand Down

0 comments on commit 6ad5c1f

Please sign in to comment.