mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Remove some format rule (#10919)
* remove some rules * format all codes with new format rule
This commit is contained in:
@@ -108,7 +108,7 @@ LegacyThreadPool::~LegacyThreadPool() {
|
||||
|
||||
// number of idle threads
|
||||
int LegacyThreadPool::getIdleThreadNum() const {
|
||||
auto * thiz = const_cast<LegacyThreadPool *>(this);
|
||||
auto *thiz = const_cast<LegacyThreadPool *>(this);
|
||||
std::lock_guard<std::mutex> lk(thiz->_idleThreadNumMutex);
|
||||
return _idleThreadNum;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ void LegacyThreadPool::init() {
|
||||
_initedFlags[i] = std::make_shared<std::atomic<bool>>(true);
|
||||
++_initedThreadNum;
|
||||
} else {
|
||||
_abortFlags[i] = std::make_shared<std::atomic<bool>>(true);
|
||||
_abortFlags[i] = std::make_shared<std::atomic<bool>>(true);
|
||||
_initedFlags[i] = std::make_shared<std::atomic<bool>>(false);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ bool LegacyThreadPool::tryShrinkPool() {
|
||||
auto before = std::chrono::high_resolution_clock::now();
|
||||
|
||||
ccstd::vector<int> threadIDsToJoin;
|
||||
int maxThreadNumToJoin = std::min(_initedThreadNum - _minThreadNum, _shrinkStep);
|
||||
int maxThreadNumToJoin = std::min(_initedThreadNum - _minThreadNum, _shrinkStep);
|
||||
|
||||
for (int i = 0; i < _maxThreadNum; ++i) {
|
||||
if ((int)threadIDsToJoin.size() >= maxThreadNumToJoin) {
|
||||
@@ -201,7 +201,7 @@ void LegacyThreadPool::stretchPool(int count) {
|
||||
}
|
||||
|
||||
if (newThreadCount > 0) {
|
||||
auto after = std::chrono::high_resolution_clock::now();
|
||||
auto after = std::chrono::high_resolution_clock::now();
|
||||
float seconds = TIME_MINUS(after, before);
|
||||
|
||||
LOGD("stretch pool from %d to %d, waste %f seconds\n", oldThreadCount, _initedThreadNum,
|
||||
@@ -210,7 +210,7 @@ void LegacyThreadPool::stretchPool(int count) {
|
||||
}
|
||||
|
||||
void LegacyThreadPool::pushTask(const std::function<void(int)> &runnable,
|
||||
TaskType type /* = DEFAULT*/) {
|
||||
TaskType type /* = DEFAULT*/) {
|
||||
if (!_isFixedSize) {
|
||||
_idleThreadNumMutex.lock();
|
||||
int idleNum = _idleThreadNum;
|
||||
@@ -218,7 +218,7 @@ void LegacyThreadPool::pushTask(const std::function<void(int)> &runnable,
|
||||
|
||||
if (idleNum > _minThreadNum) {
|
||||
if (_taskQueue.empty()) {
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
float seconds = TIME_MINUS(now, _lastShrinkTime);
|
||||
if (seconds > _shrinkInterval) {
|
||||
tryShrinkPool();
|
||||
@@ -235,7 +235,7 @@ void LegacyThreadPool::pushTask(const std::function<void(int)> &runnable,
|
||||
});
|
||||
|
||||
Task task;
|
||||
task.type = type;
|
||||
task.type = type;
|
||||
task.callback = callback;
|
||||
_taskQueue.push(task);
|
||||
|
||||
@@ -340,8 +340,8 @@ void LegacyThreadPool::setThread(int tid) {
|
||||
_abortFlags[tid]); // a copy of the shared ptr to the flag
|
||||
auto f = [this, tid, abortPtr /* a copy of the shared ptr to the abort */]() {
|
||||
std::atomic<bool> &abort = *abortPtr;
|
||||
Task task;
|
||||
bool isPop = _taskQueue.pop(task);
|
||||
Task task;
|
||||
bool isPop = _taskQueue.pop(task);
|
||||
while (true) {
|
||||
while (isPop) { // if there is anything in the queue
|
||||
std::unique_ptr<std::function<void(int)>> func(
|
||||
|
||||
Reference in New Issue
Block a user