diff --git a/.gitignore b/.gitignore index 687f872..a023e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .vscode/ - +.vs/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..62d91f8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.7) +Project(libpool) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CMakeModules/) +cmake_policy(SET CMP0037 OLD) +set(CMAKE_BUILD_TYPE Release) + +set(executable output) +set(SrcDIR ./test) +set(IncludeDIR ./include) + +include_directories(${executable} ./libpool) + +set(THREADS_PREFER_PTHREAD_FLAD ON) +find_package(Threads REQUIRED) + +file(GLOB SourceFiles + ${SrcDIR}/* +) + +add_executable(${executable} ${SourceFiles}) + +set_target_properties(${executable} PROPERTIES + CXX_STANDARD 17 + CXX_EXTENSIONS OFF +) + +target_link_libraries(${executable} + Threads::Threads +) diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000..2b43668 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "x64-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + } + ] +} \ No newline at end of file diff --git a/Stuff.lnk b/Stuff.lnk new file mode 100644 index 0000000..8842c30 Binary files /dev/null and b/Stuff.lnk differ diff --git a/libpool/libpool.cpp b/libpool/libpool.cpp new file mode 100644 index 0000000..3ffaeb1 --- /dev/null +++ b/libpool/libpool.cpp @@ -0,0 +1,5 @@ +#include "./libpool.h" + +Pool::Pool(int iNumThreads) { + +} diff --git a/libpool/libpool.h b/libpool/libpool.h index e69de29..10ac330 100644 --- a/libpool/libpool.h +++ b/libpool/libpool.h @@ -0,0 +1,36 @@ +#ifndef LIBPOOL_LIBPOOL_H_ +#define LIBPOOL_LIBPOOL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Pool { +public: + Pool(int iNumThreads = 2); + + void resize(int iNumThreads); + + template + auto addToQueue(F&& f, Args&&... args) + -> std::future::type>; + +private: + std::vector m_vWorkers; + std::queue> m_qTaskQueue; + + std::mutex m_mQueueMutex; + std::condition_variable m_cCondition; + bool m_bStop; + + int m_iThreads = 2; +}; + +#endif \ No newline at end of file diff --git a/output.exe b/output.exe new file mode 100644 index 0000000..e2c24e9 Binary files /dev/null and b/output.exe differ diff --git a/test/build.bat b/test/build.bat new file mode 100644 index 0000000..eb12e64 --- /dev/null +++ b/test/build.bat @@ -0,0 +1 @@ +g++ main.cpp ../libpool/*.cpp -I../libpool/ -pthread -o ../output.exe \ No newline at end of file diff --git a/test/main.cpp b/test/main.cpp index e69de29..b396b90 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main(int argc, char** argv) { + Pool threadPool { 5 }; + + + +}