Skip to content

Commit f8e1831

Browse files
Merge pull request #6 from jasper-yeh/synaptive/dev/jasper/COM-822-fix-gcc-11-build-issues
fix: gcc-11 build issues/warnings in thread-pool-cpp
2 parents 815f304 + 57d07d6 commit f8e1831

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

googletest

Submodule googletest updated 392 files

include/thread_pool/thread_pool_options.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <thread>
55
#include <functional>
66
#include <chrono>
7+
#include <cmath>
78

89
namespace tp
910
{
@@ -203,7 +204,7 @@ inline size_t ThreadPoolOptions::BusyWaitOptions::defaultNumIterations()
203204

204205
inline ThreadPoolOptions::BusyWaitOptions::IterationFunction ThreadPoolOptions::BusyWaitOptions::defaultIterationFunction()
205206
{
206-
return [](size_t i) { return std::chrono::microseconds(static_cast<size_t>(pow(2, i))*1000); };
207+
return [](size_t i) { return std::chrono::microseconds(static_cast<size_t>(std::pow(2, i))*1000); };
207208
}
208209

209210
inline ThreadPoolOptions::ThreadPoolOptions(size_t thread_count, size_t queue_size, size_t failed_wakeup_retry_cap, BusyWaitOptions busy_wait_options, std::chrono::microseconds rouse_period)

include/thread_pool/worker.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ inline void Worker<Task, Queue>::threadFunc(const size_t id, std::shared_ptr<Thr
389389
}
390390
}
391391
}
392-
catch (WorkerStoppedException)
392+
catch (WorkerStoppedException const&)
393393
{
394394
// Allow thread function to complete.
395395
}

tests/fixed_function.t.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ TEST(FixedFunction, allocDealloc)
115115
}
116116

117117
ASSERT_EQ(def + cop + mov, destroyed);
118-
ASSERT_EQ(2, def);
119-
ASSERT_EQ(0, cop);
120-
ASSERT_EQ(6, mov);
121-
ASSERT_EQ(0, cop_ass);
122-
ASSERT_EQ(0, mov_ass);
118+
ASSERT_EQ(2u, def);
119+
ASSERT_EQ(0u, cop);
120+
ASSERT_EQ(6u, mov);
121+
ASSERT_EQ(0u, cop_ass);
122+
ASSERT_EQ(0u, mov_ass);
123123
}
124124

125125
TEST(FixedFunction, freeFunc)

tests/thread_pool.t.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TestLinkage {
1111
size_t getWorkerIdForCurrentThread()
1212
{
13-
return *tp::detail::thread_id();
13+
return tp::detail::thread_id();
1414
}
1515

1616
size_t getWorkerIdForCurrentThread2()

tests/thread_pool_options.t.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TEST(ThreadPoolOptions, ctor)
88
{
99
tp::ThreadPoolOptions options;
1010

11-
ASSERT_EQ(1024, options.queueSize());
11+
ASSERT_EQ(1024u, options.queueSize());
1212
ASSERT_EQ(std::max<size_t>(1u, std::thread::hardware_concurrency()),
1313
options.threadCount());
1414
}
@@ -18,10 +18,10 @@ TEST(ThreadPoolOptions, modification)
1818
tp::ThreadPoolOptions options;
1919

2020
options.setThreadCount(5);
21-
ASSERT_EQ(5, options.threadCount());
21+
ASSERT_EQ(5u, options.threadCount());
2222

2323
options.setQueueSize(32);
24-
ASSERT_EQ(32, options.queueSize());
24+
ASSERT_EQ(32u, options.queueSize());
2525
}
2626

2727
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)