리눅스랑 코드 동기화

This commit is contained in:
2025-05-01 16:33:52 +09:00
parent d3161edb36
commit 4fb5bdd4cb
14 changed files with 279 additions and 144 deletions

View File

@@ -18,7 +18,7 @@ public:
void init(std::uint32_t numThreads);
template<typename _Callable, typename... _Args>
requires (!std::is_void_v<std::invoke_result_t<_Callable, _Args...>>)
requires (!std::is_void_v<std::invoke_result_t<_Callable, ThreadPool*, _Args...>>)
int enqueueJob(_Callable&& __job, std::invoke_result_t<_Callable, _Args...>& retVal, _Args&&... __args) {
if (terminate_) {
spdlog::error("Cannot run jobs on threads that terminating...");
@@ -26,8 +26,8 @@ public:
}
std::lock_guard<std::mutex> lock(jobQueueMutex);
auto boundFunc = [&retVal, __job = std::move(__job), ... __args = std::move(__args)]() mutable {
retVal = __job(std::move(__args)...);
auto boundFunc = [this, &retVal, __job = std::move(__job), ... __args = std::move(__args)]() mutable {
retVal = __job(this, std::move(__args)...);
};
auto task = std::packaged_task<void()>(std::move(boundFunc));
jobs_.push(std::move(task));
@@ -36,7 +36,7 @@ public:
return 0;
}
template<typename _Callable, typename... _Args>
requires std::is_void_v<std::invoke_result_t<_Callable, _Args...>>
requires std::is_void_v<std::invoke_result_t<_Callable, ThreadPool*, _Args...>>
int enqueueJob(_Callable&& __job, _Args&&... __args) {
if (terminate_) {
spdlog::error("Cannot run jobs on threads that terminating...");
@@ -44,8 +44,8 @@ public:
}
std::lock_guard<std::mutex> lock(jobQueueMutex);
auto boundFunc = [__job = std::move(__job), ... __args = std::move(__args)]() mutable {
__job(std::move(__args)...);
auto boundFunc = [this, __job = std::move(__job), ... __args = std::move(__args)]() mutable {
__job(this, std::move(__args)...);
};
auto task = std::packaged_task<void()>(std::move(boundFunc));
jobs_.push(std::move(task));