Skip to content

Commit 9960c48

Browse files
author
hanjun
committed
fix
1 parent 0e6d8cc commit 9960c48

14 files changed

Lines changed: 73 additions & 165 deletions

File tree

my_pb_channel/src/install/bin/cfg/my_pb_channel_cfg.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ aimrt:
33
log:
44
backends:
55
- type: console
6-
76
executor:
87
executors:
9-
- name: work_thread_pool
8+
- name: pub_thread_pool
9+
type: asio_thread
10+
- name: sub_thread_pool
1011
type: asio_thread
11-
options:
12-
thread_num: 2
1312
channel:
1413
backends:
1514
- type: local

my_pb_channel/src/module/normal_publisher_module/normal_publisher_module.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bool NormalPublisherModule::Initialize(aimrt::CoreRef core) {
2121
}
2222

2323
// Get executor handle with name "work_thread_pool",(it must be registered in aimrt config file)
24-
executor_ = ctx_ptr_->CreateExecutor("work_thread_pool");
24+
executor_ = ctx_ptr_->CreateExecutor("pub_thread_pool");
2525

2626
// Register publish
2727
publisher_ = ctx_ptr_->CreatePublisher<aimrt_samples::protocols::EventMsg>(topic_name_);

my_pb_channel/src/module/normal_subscriber_module/normal_subscriber_module.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ bool NormalSubscriberModule::Initialize(aimrt::CoreRef core) {
1818
topic_name_ = cfg_node["topic_name"].as<std::string>();
1919
}
2020

21+
executor_ = ctx_ptr_->CreateExecutor("sub_thread_pool");
2122
// Register subscriber
2223
subscriber_ = ctx_ptr_->CreateSubscriber<aimrt_samples::protocols::EventMsg>(topic_name_,
24+
executor_,
2325
std::bind(&NormalSubscriberModule::EventHandle, this, std::placeholders::_1, std::placeholders::_2));
2426

2527
} catch (const std::exception& e) {

my_pb_channel/src/module/normal_subscriber_module/normal_subscriber_module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ class NormalSubscriberModule : public aimrt::ModuleBase {
3030

3131
std::string topic_name_ = "test_topic";
3232
aimrt::context::res::Subscriber<aimrt_samples::protocols::EventMsg> subscriber_;
33+
aimrt::executor::ExecutorRef executor_;
3334
};

my_pb_rpc/cmake/GetAimRT.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include(FetchContent)
66
message(STATUS "get aimrt ...")
77

88
set(aimrt_DOWNLOAD_URL
9-
"https://github.com/AimRT/AimRT/archive/refs/tags/v1.0.0.tar.gz"
9+
"https://github.com/AimRT/AimRT/archive/refs/tags/v1.4.0.tar.gz"
1010
CACHE STRING "")
1111

1212
if(aimrt_LOCAL_SOURCE)

my_pb_rpc/src/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ add_subdirectory(protocols)
66
add_subdirectory(module/normal_client_module)
77
add_subdirectory(module/normal_server_module)
88

9-
add_subdirectory(app/my_pb_rpc_app)
9+
add_subdirectory(pkg/my_pb_rpc_pkg)
1010

1111
add_custom_target(
1212
${PROJECT_NAME}_build_all ALL
1313
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/install/bin ${CMAKE_BINARY_DIR}
14-
DEPENDS my_pb_rpc_app)
14+
DEPENDS aimrt::runtime::main
15+
my_pb_rpc_pkg)
1516

1617
# Install
1718
if(AIMRT_SAMPLES_INSTALL)

my_pb_rpc/src/app/my_pb_rpc_app/CMakeLists.txt

Lines changed: 0 additions & 27 deletions
This file was deleted.

my_pb_rpc/src/app/my_pb_rpc_app/main.cc

Lines changed: 0 additions & 64 deletions
This file was deleted.

my_pb_rpc/src/install/bin/cfg/my_pb_rpc_cfg.yaml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,29 @@
11
# AimRT core configuration
22
aimrt:
3-
log: # log configuration
4-
core_lvl: INFO # core log level, options: Trace/Debug/Info/Warn/Error/Fatal/Off, case-insensitive
5-
default_module_lvl: INFO # module default log level
6-
backends: # log backends
7-
- type: console # print to console
8-
options:
9-
color: true # colored print
10-
- type: rotate_file # print to file and rotate
11-
options:
12-
path: ./log # log file path
13-
filename: my_pb_rpc.log # log file name
14-
max_file_size_m: 4 # log file max size, unit: MB
15-
max_file_num: 10 # max log file num, 0 means unlimited
16-
executor: # executor configuration
17-
executors: # you want to create executors here
18-
- name: work_thread_pool # name
3+
log:
4+
backends:
5+
- type: console
6+
executor:
7+
executors:
8+
- name: client_thread_pool
199
type: asio_thread
20-
options:
21-
thread_num: 2 # thread num
22-
- name: timeout_handle # name
23-
type: time_wheel
24-
options:
25-
bind_executor: work_thread_pool
26-
rpc: # rpc configuration
27-
backends: # rpc backends
28-
- type: local # use local backend
29-
options:
30-
timeout_executor: timeout_handle # set timeout executor
31-
clients_options: # client endpoint options
32-
- func_name: "(.*)" # select some function (support regex)
10+
- name: server_thread_pool
11+
type: asio_thread
12+
rpc:
13+
backends:
14+
- type: local
15+
clients_options:
16+
- func_name: "(.*)"
3317
enable_backends: [local]
34-
servers_options: # server endpoint options
35-
- func_name: "(.*)" # select some function (support regex)
18+
servers_options:
19+
- func_name: "(.*)"
3620
enable_backends: [local]
3721

22+
module:
23+
pkgs:
24+
- path: ./libmy_pb_rpc_pkg.so
25+
enable_modules: [NormalRpcClientModule, NormalRpcServerModule]
3826
# Custom module configuration
39-
# the framework will generate a temporary configuration file for each module,
40-
# and the developer can get the configuration file path through the Configurator interface.
4127
NormalRpcClientModule:
4228
rpc_frq: 1
4329

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
./my_pb_rpc_app ./cfg/my_pb_rpc_cfg.yaml
3+
./aimrt_main --cfg_file_path=./cfg/my_pb_rpc_cfg.yaml

0 commit comments

Comments
 (0)