Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
Expand All @@ -23,7 +23,7 @@ AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Setup Dependencies
run: |
brew install ninja
brew install ninja cmake

- name: Cache jsoncpp
id: cache-jsoncpp
Expand Down Expand Up @@ -72,6 +72,7 @@ jobs:
if: steps.cache-gflags.outputs.cache-hit != 'true'
run: |
cmake -S gflags-2.2.2 -B build-gflags \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags \
Expand All @@ -96,6 +97,7 @@ jobs:
if: steps.cache-glog.outputs.cache-hit != 'true'
run: |
cmake -S glog-0.6.0 -B build-glog \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DWITH_PKGCONFIG=OFF \
Expand All @@ -108,6 +110,7 @@ jobs:
- name: Configure
run: |
cmake -S . -B build_${{matrix.build_type}} \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if (POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
project(myframe
VERSION 0.9.8
VERSION 0.9.9
LANGUAGES CXX
)

Expand All @@ -13,6 +13,7 @@ option(MYFRAME_GENERATE_EXAMPLE "Generate example library" ON)
option(MYFRAME_GENERATE_TEST "Generate test executable program" ON)
option(MYFRAME_INSTALL_TEMPLATE "Install template project" ON)
option(MYFRAME_INSTALL_LAUNCHER "Install launcher program" ON)
option(MYFRAME_ENABLE_ASAN "Enable ASAN" OFF)

### cmake module
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
Expand Down
8 changes: 8 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ if (jsoncpp_lib_type STREQUAL "STATIC_LIBRARY")
JsonCpp::JsonCpp
)
endif ()
if (MYFRAME_ENABLE_ASAN)
add_compile_options(
"$<$<CXX_COMPILER_ID:GNU,Clang>:-fsanitize=address>"
)
add_link_options(
"$<$<CXX_COMPILER_ID:GNU,Clang>:-fsanitize=address>"
)
endif ()

### actor
add_library(example_actor_helloworld SHARED example_actor_helloworld.cpp)
Expand Down
6 changes: 2 additions & 4 deletions examples/example_actor_concurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class ExampleActorConcurrent : public myframe::Actor {
return distrib(engine);
}

int Init(const char* param) override {
(void)param;
int Init() override {
return 0;
}

Expand All @@ -42,8 +41,7 @@ class ExampleActorConcurrent : public myframe::Actor {

class ExampleActorConcurrentTrigger : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
state_ = {
{"actor.ExampleActorConcurrent.1", false},
{"actor.ExampleActorConcurrent.2", false},
Expand Down
12 changes: 4 additions & 8 deletions examples/example_actor_concurrent.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@
"actor":{
"ExampleActorConcurrentTrigger":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
],
"ExampleActorConcurrent":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
},
{
"instance_name":"2",
"instance_params":""
"instance_name":"2"
},
{
"instance_name":"3",
"instance_params":""
"instance_name":"3"
}
]
}
Expand Down
3 changes: 1 addition & 2 deletions examples/example_actor_helloworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Author: 李柯鹏 <[email protected]>
class ExampleActorHelloWorld : public myframe::Actor {
public:
/* actor模块加载完毕后调用 */
int Init(const char* param) override {
(void)param;
int Init() override {
auto mailbox = GetMailbox();
/* 构造 hello,world 消息发送给自己 */
mailbox->Send(mailbox->Addr(), std::string("hello,world"));
Expand Down
3 changes: 1 addition & 2 deletions examples/example_actor_helloworld.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"actor":{
"ExampleActorHelloWorld":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
]
}
Expand Down
9 changes: 3 additions & 6 deletions examples/example_actor_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ int random(int min, int max) {

class ExampleActorSerial1 : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
auto mailbox = GetMailbox();
mailbox->Send("actor.ExampleActorSerial1.1",
std::make_shared<myframe::Msg>(""));
Expand All @@ -45,8 +44,7 @@ class ExampleActorSerial1 : public myframe::Actor {

class ExampleActorSerial2 : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
return 0;
}

Expand All @@ -65,8 +63,7 @@ class ExampleActorSerial2 : public myframe::Actor {

class ExampleActorSerial3 : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
return 0;
}

Expand Down
9 changes: 3 additions & 6 deletions examples/example_actor_serial.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
"actor":{
"ExampleActorSerial1":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
],
"ExampleActorSerial2":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
],
"ExampleActorSerial3":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
]
}
Expand Down
6 changes: 2 additions & 4 deletions examples/example_actor_subscribe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Author: 李柯鹏 <[email protected]>

class ExampleActorPub : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
Timeout("1000ms", 100);
return 0;
}
Expand All @@ -41,8 +40,7 @@ class ExampleActorPub : public myframe::Actor {

class ExampleActorSub : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
Subscribe("actor.ExampleActorPub.1");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions examples/example_actor_subscribe.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"actor":{
"ExampleActorPub":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
],
"ExampleActorSub":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
]
}
Expand Down
3 changes: 1 addition & 2 deletions examples/example_actor_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Author: 李柯鹏 <[email protected]>

class ExampleActorTimer : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
/* 设置超时时间为 100 * 10 ms */
Timeout("1000ms", 10);
return 0;
Expand Down
3 changes: 1 addition & 2 deletions examples/example_actor_timer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"actor":{
"ExampleActorTimer":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
]
}
Expand Down
3 changes: 1 addition & 2 deletions examples/example_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Author: 李柯鹏 <[email protected]>

class ExampleActorConfig : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
auto conf = GetConfig();
LOG(INFO) << GetActorName() << " pending queue size "
<< GetMailbox()->GetPendingQueueSize();
Expand Down
9 changes: 3 additions & 6 deletions examples/example_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class ExampleNode : public myframe::Actor {
// ...
}

int Init(const char* param) override {
(void)param;
int Init() override {
// 启动订阅监听程序
// 收到消息调用OnSubMsg()回调函数将消息发送给framework的组件

Expand Down Expand Up @@ -106,8 +105,7 @@ class ExampleNode : public myframe::Actor {
*/
class ExampleNodePub : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
Timeout("1000ms", 100);
return 0;
}
Expand Down Expand Up @@ -141,8 +139,7 @@ class ExampleNodePub : public myframe::Actor {
*/
class ExampleNodeSub : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
Subscribe(g_topic, "TEXT", myframe::Msg::TransMode::kDDS);
return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions examples/example_thread_quit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class ExampleThreadQuit : public myframe::Actor {
LOG(INFO) << "thread quit example quit";
}

int Init(const char* param) override {
(void)param;
int Init() override {
th_run_.store(true);
th_ = std::thread([this](){
while (th_run_.load()) {
Expand Down
3 changes: 1 addition & 2 deletions examples/example_thread_quit.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"actor":{
"ExampleThreadQuit":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
]
}
Expand Down
3 changes: 1 addition & 2 deletions examples/example_trans_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class TransObj {

class ExampleActorTransObj : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions examples/example_worker_actor_interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Author: 李柯鹏 <[email protected]>
/// 回显worker发来的消息
class ExampleActorInteractive : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions examples/example_worker_actor_interactive.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"actor":{
"ExampleActorInteractive":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
]
},
Expand Down
3 changes: 1 addition & 2 deletions examples/example_worker_interactive_with_3rd_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ class ExampleWorkerInteractiveWith3rdFrame : public myframe::Worker {

class ExampleActorInteractiveWith3rdFrame : public myframe::Actor {
public:
int Init(const char* param) override {
(void)param;
int Init() override {
Timeout("100ms", 10);
return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions examples/example_worker_interactive_with_3rd_frame.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"actor":{
"ExampleActorInteractiveWith3rdFrame":[
{
"instance_name":"1",
"instance_params":""
"instance_name":"1"
}
]
},
Expand Down
11 changes: 11 additions & 0 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ if (jsoncpp_lib_type STREQUAL "STATIC_LIBRARY")
)
endif ()

if (MYFRAME_ENABLE_ASAN)
target_compile_options(${DIR_NAME}
PRIVATE
"$<$<CXX_COMPILER_ID:GNU,Clang>:-fsanitize=address>"
)
target_link_options(${DIR_NAME}
PRIVATE
"$<$<CXX_COMPILER_ID:GNU,Clang>:-fsanitize=address>"
)
endif ()

### install
install(TARGETS ${DIR_NAME}
LIBRARY DESTINATION ${MYFRAME_LIB_DIR}
Expand Down
Loading
Loading