Browse Source

bugfix: 修复了添加辅助线程后,可能出现的唤醒休眠问题

ChunelFeng 11 months ago
parent
commit
3a6022a615
4 changed files with 5 additions and 9 deletions
  1. +1
    -1
      CMakeLists.txt
  2. +1
    -1
      src/UtilsCtrl/ThreadPool/Thread/UThreadSecondary.h
  3. +1
    -5
      src/UtilsCtrl/ThreadPool/UThreadPool.cpp
  4. +2
    -2
      src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h

+ 1
- 1
CMakeLists.txt View File

@ -7,7 +7,7 @@ message("* | |____ | | | | *")
message("* \\_____| |_| |_| *")
message("* * * * * * * * * * * * * * * * *")
cmake_minimum_required(VERSION 3.2.5)
cmake_minimum_required(VERSION 3.5.0)
project(CThreadPool VERSION 1.2.1)

+ 1
- 1
src/UtilsCtrl/ThreadPool/Thread/UThreadSecondary.h View File

@ -70,7 +70,7 @@ protected:
if (popPoolTask(task)) {
runTask(task);
} else {
//
//
waitRunTask(config_->queue_emtpy_interval_);
}
}

+ 1
- 5
src/UtilsCtrl/ThreadPool/UThreadPool.cpp View File

@ -191,12 +191,8 @@ CStatus UThreadPool::releaseSecondaryThread(CInt size) {
CIndex UThreadPool::dispatch(CIndex origIndex) {
CIndex realIndex = 0;
if (CGRAPH_DEFAULT_TASK_STRATEGY == origIndex) {
/**
* [0, default_thread_size_) thread queue来调度
* [default_thread_size_, max_thread_size_) pool queue来调度
*/
realIndex = cur_index_++;
if (cur_index_ >= config_.max_thread_size_ || cur_index_ < 0) {
if (cur_index_ >= config_.default_thread_size_ || cur_index_ < 0) {
cur_index_ = 0;
}
} else {

+ 2
- 2
src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h View File

@ -52,13 +52,13 @@ static const int CGRAPH_LONG_TIME_TASK_STRATEGY = -101;
static const int CGRAPH_DEFAULT_THREAD_SIZE = 8; // 线
static const int CGRAPH_SECONDARY_THREAD_SIZE = 0; // 线
static const int CGRAPH_MAX_THREAD_SIZE = 16; // 线
static const int CGRAPH_MAX_TASK_STEAL_RANGE = 2; //
static const int CGRAPH_MAX_TASK_STEAL_RANGE = 7; //
static const bool CGRAPH_BATCH_TASK_ENABLE = false; //
static const int CGRAPH_MAX_LOCAL_BATCH_SIZE = 2; //
static const int CGRAPH_MAX_POOL_BATCH_SIZE = 2; //
static const int CGRAPH_MAX_STEAL_BATCH_SIZE = 2; //
static const int CGRAPH_PRIMARY_THREAD_BUSY_EPOCH = 10; // 线wait状态的轮数
static const CMSec CGRAPH_PRIMARY_THREAD_EMPTY_INTERVAL = 3; // 线
static const CMSec CGRAPH_PRIMARY_THREAD_EMPTY_INTERVAL = 1000; // 线
static const int CGRAPH_SECONDARY_THREAD_TTL = 10; // 线ttls
static const bool CGRAPH_MONITOR_ENABLE = false; //
static const CSec CGRAPH_MONITOR_SPAN = 5; // 线s

Loading…
Cancel
Save