Skip to content

Commit 39b32d5

Browse files
add: max_executor_thread_num
1 parent e2a7464 commit 39b32d5

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

src/libmodelbox/base/include/modelbox/base/executor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class Executor {
3333

3434
virtual ~Executor();
3535

36+
void SetThreadCount(int thread_count);
37+
3638
template <typename func, typename... ts>
3739
auto Run(func &&fun, int32_t priority, ts &&...params)
3840
-> std::future<typename std::result_of<func(ts...)>::type> {

src/libmodelbox/engine/flowunit_data_executor.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Executor::Executor(int thread_count) {
3434

3535
Executor::~Executor() { thread_pool_ = nullptr; }
3636

37+
void Executor::SetThreadCount(int thread_count){
38+
thread_pool_->SetThreadSize(thread_count);
39+
}
40+
3741
FlowUnitExecContext::FlowUnitExecContext(
3842
std::shared_ptr<FlowUnitDataContext> data_ctx)
3943
: data_ctx_(std::move(data_ctx)) {}

src/libmodelbox/engine/flowunit_manager.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ Status FlowUnitManager::Initialize(
5959
SetDeviceManager(std::move(device_mgr));
6060
Status status;
6161
status = InitFlowUnitFactory(driver);
62+
63+
if (config != nullptr){
64+
max_executor_thread_num = config->GetUint32("graph.max_executor_thread_num", 0);
65+
} else {
66+
max_executor_thread_num = 0;
67+
}
68+
6269
if (status != STATUS_SUCCESS) {
6370
return status;
6471
}

src/libmodelbox/include/modelbox/flowunit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ class FlowUnitManager {
612612

613613
std::shared_ptr<DeviceManager> GetDeviceManager();
614614

615+
int max_executor_thread_num;
616+
615617
private:
616618
Status CheckParams(const std::string &unit_name, const std::string &unit_type,
617619
const std::string &unit_device_id);

0 commit comments

Comments
 (0)