GeezerVison is showing github.com — [feat] add _CGRAPH_GPARAM_RWLOCK_ENABLE_ · feiyunwill/CGraph@441296c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: CMakeLists.txt +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,12 @@ option(CGRAPH_BUILD_PERFORMANCE_TESTS "Enables builds of performance tests" OFF) | 29 | 29 | # 此宏可以在纯并发的微小任务下,用于提升整体性能。主要用于在性能测试的情况下使用,一般情况不推荐打开 | 30 | 30 | # add_definitions(-D_CGRAPH_PARALLEL_MICRO_BATCH_ENABLE_) | 31 | 31 |
| | 32 | +# 此宏用于在读写GParam加锁的时候,加锁方式修改为读写锁的情况 | | 33 | +# 仅在cpp17或以上版本生效 | | 34 | +# 打开后会在多读少写的情况下有性能优化 | | 35 | +# 副作用是GParam中的锁无法递归上锁,一般情况下可忽略影响 | | 36 | +# add_definitions(-D_CGRAPH_GPARAM_RWLOCK_ENABLE_) | | 37 | + | 32 | 38 | # add CGraph environment info | 33 | 39 | include(cmake/CGraph-env-include.cmake) | 34 | 40 |
| |
Collapse file Copy file name to clipboardExpand all lines: python/PyCGraph.cpp +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -124,8 +124,10 @@ PYBIND11_MODULE(PyCGraph, m) { | 124 | 124 | py::return_value_policy::reference) | 125 | 125 | .def("getCode", &CStatus::getCode) | 126 | 126 | .def("getInfo", &CStatus::getInfo) | | 127 | + .def("reset", &CStatus::reset) | 127 | 128 | .def("isOK", &CStatus::isOK) | 128 | | - .def("isErr", &CStatus::isErr); | | 129 | + .def("isErr", &CStatus::isErr) | | 130 | + .def("isCrash", &CStatus::isCrash); | 129 | 131 |
| 130 | 132 | py::class_<GAspect, PywGAspect, std::unique_ptr<GAspect, py::nodelete> >(m, "GAspect") | 131 | 133 | .def(py::init<>()) | |
Collapse file Copy file name to clipboardExpand all lines: python/tutorial/T01-Simple.py +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,8 +23,11 @@ def tutorial_simple(): | 23 | 23 |
| 24 | 24 | status: CStatus = pipeline.init() | 25 | 25 | if status.isErr(): | 26 | | - # please check api return value. | 27 | | - print('pipeline init failed, error code is {0}.'.format(status.getCode())) | | 26 | + # please check api return status | | 27 | + # ret_code == 0 is ok, default | | 28 | + # ret_code < 0 means error, ex: return CStatus(-1, "my error info") | | 29 | + print('pipeline init failed, error code is {0}, error info is {1}'.format( | | 30 | + status.getCode(), status.getInfo())) | 28 | 31 | return | 29 | 32 |
| 30 | 33 | for i in range(0, 3): | |
Collapse file Copy file name to clipboardExpand all lines: src/UtilsCtrl/UtilsDefine.h +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,11 +35,11 @@ CGRAPH_NAMESPACE_BEGIN | 35 | 35 | using CGRAPH_LOCK_GUARD = std::lock_guard<std::mutex>; | 36 | 36 | using CGRAPH_UNIQUE_LOCK = std::unique_lock<std::mutex>; | 37 | 37 |
| 38 | | -#if __cplusplus >= 201703L | | 38 | +#if __cplusplus >= 201703L && _CGRAPH_GPARAM_RWLOCK_ENABLE_ | 39 | 39 | using CGRAPH_READ_LOCK = std::shared_lock<std::shared_mutex>; | 40 | 40 | using CGRAPH_WRITE_LOCK = std::unique_lock<std::shared_mutex>; | 41 | 41 | #else | 42 | | - using CGRAPH_READ_LOCK = std::lock_guard<std::recursive_mutex>; // C++11和14不支持读写锁,使用mutex替代 | | 42 | + using CGRAPH_READ_LOCK = std::lock_guard<std::recursive_mutex>; // C++11和14不支持读写锁,使用 recursive_mutex 替代 | 43 | 43 | using CGRAPH_WRITE_LOCK = std::lock_guard<std::recursive_mutex>; | 44 | 44 | #endif | 45 | 45 |
| |
|