File tree 2 files changed +4
-5
lines changed
2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -341,8 +341,8 @@ sudo make install
341
341
## 注意事项
342
342
343
343
#### 雷区
344
- 1 . 不要在任务中操纵组件,如:` submit([&br]{br.wait_tasks();}); ` (递归加锁问题) <br >
345
- 2 . 不要在回调中操纵组件,如:` set_tick_cb([&sp]{sp.suspend();}); ` (递归加锁问题) <br >
344
+ 1 . 不要在任务中操纵组件,如:` submit([&br]{br.wait_tasks();}); ` 会阻塞线程 <br >
345
+ 2 . 不要在回调中操纵组件,如:` set_tick_cb([&sp]{sp.suspend();}); ` <br >
346
346
3 . 不要让workbranch先于supervisor析构(空悬指针问题)。
347
347
348
348
#### 接口安全性
Original file line number Diff line number Diff line change @@ -86,11 +86,10 @@ class supervisor {
86
86
* @param cb callback function
87
87
*/
88
88
void set_tick_cb (tick_callback_t cb) {
89
- std::lock_guard<std::mutex> lock (spv_lok);
90
89
tick_cb = cb;
91
90
}
92
91
private:
93
-
92
+ // loop func
94
93
void mission () {
95
94
while (!stop) {
96
95
try {
@@ -101,7 +100,7 @@ class supervisor {
101
100
auto tknums = pbr->num_tasks ();
102
101
auto wknums = pbr->num_workers ();
103
102
// adjust
104
- if (tknums) { // block number of tasks
103
+ if (tknums) {
105
104
sz_t nums = std::min (wmax-wknums, tknums-wknums);
106
105
for (sz_t i = 0 ; i < nums; ++i) {
107
106
pbr->add_worker (); // quick add
You can’t perform that action at this time.
0 commit comments