mirror of
https://github.com/HappyTanuki/BumbleCee.git
synced 2025-10-26 01:45:15 +00:00
정리 중..
This commit is contained in:
8
.vscode/tasks.json
vendored
8
.vscode/tasks.json
vendored
@@ -4,8 +4,8 @@
|
|||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"type": "cppbuild",
|
"type": "cppbuild",
|
||||||
"label": "make",
|
"label": "ninja",
|
||||||
"command": "make",
|
"command": "ninja",
|
||||||
"args": [],
|
"args": [],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}/build/"
|
"cwd": "${workspaceFolder}/build/"
|
||||||
@@ -21,7 +21,9 @@
|
|||||||
"label": "cmake",
|
"label": "cmake",
|
||||||
"command": "cmake",
|
"command": "cmake",
|
||||||
"args": [
|
"args": [
|
||||||
".."
|
"..",
|
||||||
|
"-G",
|
||||||
|
"Ninja"
|
||||||
],
|
],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}/build/"
|
"cwd": "${workspaceFolder}/build/"
|
||||||
|
|||||||
@@ -14,21 +14,15 @@ aux_source_directory("src/Settings" settings)
|
|||||||
aux_source_directory("src/Utils" settings)
|
aux_source_directory("src/Utils" settings)
|
||||||
add_executable(${BOT_NAME} ${coresrc} ${commands} ${settings})
|
add_executable(${BOT_NAME} ${coresrc} ${commands} ${settings})
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
|
||||||
add_definitions( -DBOOST_ALL_NO_LIB )
|
|
||||||
set( Boost_USE_STATIC_LIBS ON )
|
set( Boost_USE_STATIC_LIBS ON )
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
find_package(OpenSSL REQUIRED)
|
|
||||||
find_package(Boost REQUIRED)
|
find_package(Boost REQUIRED)
|
||||||
|
|
||||||
target_include_directories(${BOT_NAME} PUBLIC
|
target_include_directories(${BOT_NAME} PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
${OPENSSL_INCLUDE_DIR}
|
|
||||||
/usr/include/opus
|
/usr/include/opus
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,10 +31,5 @@ target_link_libraries(${BOT_NAME}
|
|||||||
opus
|
opus
|
||||||
ogg
|
ogg
|
||||||
oggz
|
oggz
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${OPENSSL_CRYPTO_LIBRARY}
|
|
||||||
${OPENSSL_SSL_LIBRARY}
|
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
link_directories(/usr/lib)
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <memory>
|
|
||||||
#include <functional>
|
|
||||||
#include <thread>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <queue>
|
|
||||||
|
|
||||||
namespace bumbleBee {
|
|
||||||
template <typename FuncRet, typename FuncParam>
|
|
||||||
class ThreadPool {
|
|
||||||
public:
|
|
||||||
ThreadPool() = delete;
|
|
||||||
ThreadPool(std::int32_t threadCount);
|
|
||||||
|
|
||||||
std::thread::id execute(std::function<FuncRet(FuncParam)> function);
|
|
||||||
void gracefullStop(std::thread::id thread);
|
|
||||||
void gracefullAllStop();
|
|
||||||
private:
|
|
||||||
std::mutex mutex_;
|
|
||||||
std::condition_variable condition_;
|
|
||||||
std::int32_t threadCount_;
|
|
||||||
std::vector<std::thread> threadPool_;
|
|
||||||
std::unordered_map<std::thread, std::bool> terminating_;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#include "Utils/ThreadPool.hpp"
|
|
||||||
|
|
||||||
namespace bumbleBee {
|
|
||||||
|
|
||||||
template <typename FuncRet, typename FuncParam>
|
|
||||||
ThreadPool<FuncRet, FuncParam>::ThreadPool(std::int32_t threadCount) {
|
|
||||||
this.threadCount = threadCount;
|
|
||||||
while (threadCount--) {
|
|
||||||
threadPool.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FuncRet, typename FuncParam>
|
|
||||||
void ThreadPool<FuncRet, FuncParam>::gracefullAllStop() {
|
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
|
||||||
for (auto& thread : threadPool_) {
|
|
||||||
terminating_[thread] = true;
|
|
||||||
condition_.notify_all();
|
|
||||||
}
|
|
||||||
for (auto& thread : threadPool_) {
|
|
||||||
if (thread.joinable()) {
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
threadPool_.clear();
|
|
||||||
terminating_.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user