Skip to content

Commit 2b8c9d3

Browse files
committed
refactor: ThreadPool -> ThreadPoolExecutor
refactor: ServerStatus -> GamingStatus
1 parent 721466d commit 2b8c9d3

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/legacy/api/FileSystemAPI.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "engine/EngineManager.h"
55
#include "engine/LocalShareData.h"
66
#include "engine/TimeTaskSystem.h"
7-
#include "ll/api/service/ServerInfo.h"
7+
#include "ll/api/service/GamingStatus.h"
88
#include "ll/api/utils/StringUtils.h"
99

1010
#include <corecrt_io.h>
@@ -237,14 +237,14 @@ Local<Value> FileClass::read(const Arguments& args) {
237237
int cnt = args[0].toInt();
238238
script::Global<Function> callbackFunc{args[1].asFunction()};
239239

240-
pool.addTask(
240+
pool.execute(
241241
[cnt,
242242
fp{&file},
243243
isBinary{isBinary},
244244
lock{&lock},
245245
callback{std::move(callbackFunc)},
246246
engine{EngineScope::currentEngine()}]() -> void {
247-
if ((ll::getServerStatus() != ll::ServerStatus::Running)) return;
247+
if ((ll::getGamingStatus() != ll::GamingStatus::Running)) return;
248248
if (!EngineManager::isValid(engine)) return;
249249

250250
char* buf = new char[cnt];
@@ -276,9 +276,9 @@ Local<Value> FileClass::readLine(const Arguments& args) {
276276
try {
277277
script::Global<Function> callbackFunc{args[0].asFunction()};
278278

279-
pool.addTask([fp{&file}, lock{&lock}, callback{std::move(callbackFunc)}, engine{EngineScope::currentEngine()}](
279+
pool.execute([fp{&file}, lock{&lock}, callback{std::move(callbackFunc)}, engine{EngineScope::currentEngine()}](
280280
) {
281-
if ((ll::getServerStatus() != ll::ServerStatus::Running)) return;
281+
if ((ll::getGamingStatus() != ll::GamingStatus::Running)) return;
282282
if (!EngineManager::isValid(engine)) return;
283283

284284
std::string buf;
@@ -304,12 +304,12 @@ Local<Value> FileClass::readAll(const Arguments& args) {
304304
try {
305305
script::Global<Function> callbackFunc{args[0].asFunction()};
306306

307-
pool.addTask([fp{&file},
307+
pool.execute([fp{&file},
308308
isBinary{isBinary},
309309
lock{&lock},
310310
callback{std::move(callbackFunc)},
311311
engine{EngineScope::currentEngine()}]() {
312-
if ((ll::getServerStatus() != ll::ServerStatus::Running)) return;
312+
if ((ll::getGamingStatus() != ll::GamingStatus::Running)) return;
313313
if (!EngineManager::isValid(engine)) return;
314314

315315
lock->lock();
@@ -351,13 +351,13 @@ Local<Value> FileClass::write(const Arguments& args) {
351351
script::Global<Function> callbackFunc;
352352
if (args.size() >= 2) callbackFunc = args[1].asFunction();
353353

354-
pool.addTask([fp{&file},
354+
pool.execute([fp{&file},
355355
lock{&lock},
356356
data{std::move(data)},
357357
isString,
358358
callback{std::move(callbackFunc)},
359359
engine{EngineScope::currentEngine()}]() {
360-
if ((ll::getServerStatus() != ll::ServerStatus::Running)) return;
360+
if ((ll::getGamingStatus() != ll::GamingStatus::Running)) return;
361361
if (!EngineManager::isValid(engine)) return;
362362

363363
lock->lock();
@@ -390,12 +390,12 @@ Local<Value> FileClass::writeLine(const Arguments& args) {
390390
script::Global<Function> callbackFunc;
391391
if (args.size() >= 2) callbackFunc = args[1].asFunction();
392392

393-
pool.addTask([fp{&file},
393+
pool.execute([fp{&file},
394394
lock{&lock},
395395
data{std::move(data)},
396396
callback{std::move(callbackFunc)},
397397
engine{EngineScope::currentEngine()}]() {
398-
if ((ll::getServerStatus() != ll::ServerStatus::Running)) return;
398+
if ((ll::getGamingStatus() != ll::GamingStatus::Running)) return;
399399
if (!EngineManager::isValid(engine)) return;
400400

401401
lock->lock();
@@ -472,7 +472,7 @@ Local<Value> FileClass::isEOF(const Arguments&) {
472472

473473
Local<Value> FileClass::flush(const Arguments&) {
474474
try {
475-
pool.addTask([fp{&file}, lock{&lock}]() {
475+
pool.execute([fp{&file}, lock{&lock}]() {
476476
lock->lock();
477477
fp->flush();
478478
lock->unlock();

src/legacy/engine/LocalShareData.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "main/Configs.h"
44

5-
#include <ll/api/thread/ThreadPool.h>
5+
#include <ll/api/thread/ThreadPoolExecutor.h>
66
#include <mutex>
77

88
// DLL本地共享数据
@@ -12,7 +12,7 @@ LocalDataType* localShareData;
1212
std::vector<RegCmdQueue> toRegCmdQueue;
1313

1414
// 线程池
15-
ll::thread::ThreadPool pool(LLSE_POOL_THREAD_COUNT);
15+
ll::thread::ThreadPoolExecutor pool("LSE_POOL", LLSE_POOL_THREAD_COUNT);
1616

1717
// std::mutex messageLoopLock;
1818

src/legacy/engine/LocalShareData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include "api/APIHelp.h"
33

4-
#include <ll/api/thread/ThreadPool.h>
4+
#include <ll/api/thread/ThreadPoolExecutor.h>
55
#include <map>
66
#include <mutex>
77
#include <string>
@@ -54,7 +54,7 @@ extern LocalDataType* localShareData;
5454
extern std::vector<RegCmdQueue> toRegCmdQueue;
5555

5656
// 线程池
57-
extern ll::thread::ThreadPool pool;
57+
extern ll::thread::ThreadPoolExecutor pool;
5858

5959
// extern std::mutex messageLoopLock;
6060

0 commit comments

Comments
 (0)