Skip to content

Commit

Permalink
build: bump to cpp17 and update both copies of threadpool.h
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Feb 18, 2024
1 parent 585bb61 commit f4e37ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
all: debug

debug:
g++ -pg -std=c++11 -g -O3 edt.hpp -ffast-math -pthread -o edt
g++ -pg -std=c++17 -g -O3 edt.hpp -ffast-math -pthread -o edt

shared:
g++ -fPIC -shared -std=c++11 -O3 edt.hpp -ffast-math -pthread -o edt.so
g++ -fPIC -shared -std=c++17 -O3 edt.hpp -ffast-math -pthread -o edt.so

test: FORCE
g++ -pg -std=c++11 -g -O3 test.cpp -ffast-math -pthread -o test
g++ -pg -std=c++17 -g -O3 test.cpp -ffast-math -pthread -o test

FORCE:
9 changes: 5 additions & 4 deletions cpp/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ freely, subject to the following restrictions:
Notice of Alteration
William Silversmith
May 2019
May 2019, December 2023
- The license file was moved from a seperate file to the top of this one.
- Created public "join" member function from destructor code.
- Created public "start" member function from constructor code.
- Used std::invoke_result_t to update to modern C++
*/

#ifndef THREAD_POOL_H
Expand All @@ -47,7 +48,7 @@ class ThreadPool {
ThreadPool(size_t);
template<class F, class... Args>
auto enqueue(F&& f, Args&&... args)
-> std::future<typename std::result_of<F(Args...)>::type>;
-> std::future<std::invoke_result_t<F, Args...>>;
void start(size_t);
void join();
~ThreadPool();
Expand Down Expand Up @@ -99,9 +100,9 @@ void ThreadPool::start(size_t threads) {
// add new work item to the pool
template<class F, class... Args>
auto ThreadPool::enqueue(F&& f, Args&&... args)
-> std::future<typename std::result_of<F(Args...)>::type>
-> std::future<std::invoke_result_t<F, Args...>>
{
using return_type = typename std::result_of<F(Args...)>::type;
using return_type = std::invoke_result_t<F, Args...>;

auto task = std::make_shared< std::packaged_task<return_type()> >(
std::bind(std::forward<F>(f), std::forward<Args>(args)...)
Expand Down
4 changes: 2 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def __repr__(self):
extra_compile_args = []
if sys.platform == 'win32':
extra_compile_args += [
'/std:c++11', '/O2'
'/std:c++17', '/O2'
]
else:
extra_compile_args += [
'-std=c++11', '-O3', '-ffast-math', '-pthread'
'-std=c++17', '-O3', '-ffast-math', '-pthread'
]

if sys.platform == 'darwin':
Expand Down
2 changes: 1 addition & 1 deletion python/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ freely, subject to the following restrictions:
Notice of Alteration
William Silversmith
May 2019
May 2019, December 2023
- The license file was moved from a seperate file to the top of this one.
- Created public "join" member function from destructor code.
Expand Down

0 comments on commit f4e37ba

Please sign in to comment.