From dd8053b23067cc8c6c6b6032edaa890424eec0b0 Mon Sep 17 00:00:00 2001 From: Sonullx Liu Date: Mon, 9 Nov 2020 20:29:06 +0800 Subject: [PATCH 1/2] Change code style in memory_unittest.cc (#148) * style: change code style in memory_unittest.cc --- test/memory_unittest.cc | 44 +++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/test/memory_unittest.cc b/test/memory_unittest.cc index 7827535f..9bf42d7d 100644 --- a/test/memory_unittest.cc +++ b/test/memory_unittest.cc @@ -1,3 +1,21 @@ +/* + Copyright (c) 2020 Sogou, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author: Liu Yang (liuyang216492@sogou-inc.com) +*/ + #include #include #include "workflow/WFTaskFactory.h" @@ -6,37 +24,37 @@ TEST(memory_unittest, dismiss) { std::vector tasks; - auto http_task = WFTaskFactory::create_http_task("https://sogou.com", 0, 0, nullptr); + auto *http_task = WFTaskFactory::create_http_task("http://www.sogou.com", 0, 0, nullptr); tasks.push_back(http_task); - auto redis_task = WFTaskFactory::create_redis_task("redis://username:password@127.0.0.1:6676/1", 0, nullptr); + auto *redis_task = WFTaskFactory::create_redis_task("redis://username:password@127.0.0.1:6676/1", 0, nullptr); tasks.push_back(redis_task); - auto mysql_task = WFTaskFactory::create_mysql_task("mysql://username:password@127.0.0.1:8899/db", 0, nullptr); + auto *mysql_task = WFTaskFactory::create_mysql_task("mysql://username:password@127.0.0.1:8899/db", 0, nullptr); tasks.push_back(mysql_task); - auto timer_task = WFTaskFactory::create_timer_task(0, nullptr); + auto *timer_task = WFTaskFactory::create_timer_task(0, nullptr); tasks.push_back(timer_task); - auto counter_task = WFTaskFactory::create_counter_task("", 0, nullptr); + auto *counter_task = WFTaskFactory::create_counter_task("", 0, nullptr); tasks.push_back(counter_task); - auto go_task = WFTaskFactory::create_go_task("", [](){}); + auto *go_task = WFTaskFactory::create_go_task("", [](){}); tasks.push_back(go_task); - auto thread_task = WFThreadTaskFactory::create_thread_task("", [](int *, int *){}, nullptr); + auto *thread_task = WFThreadTaskFactory::create_thread_task("", [](int *, int *){}, nullptr); tasks.push_back(thread_task); - auto graph_task = WFTaskFactory::create_graph_task(nullptr); - auto &node_a = graph_task->create_graph_node(WFTaskFactory::create_timer_task(0, nullptr)); - auto &node_b = graph_task->create_graph_node(WFTaskFactory::create_timer_task(0, nullptr)); + auto *graph_task = WFTaskFactory::create_graph_task(nullptr); + auto& node_a = graph_task->create_graph_node(WFTaskFactory::create_timer_task(0, nullptr)); + auto& node_b = graph_task->create_graph_node(WFTaskFactory::create_timer_task(0, nullptr)); node_a -->-- node_b; tasks.push_back(graph_task); - auto parallel_work = Workflow::create_parallel_work(nullptr); - for (auto task : tasks) + auto *parallel_work = Workflow::create_parallel_work(nullptr); + for (auto *task : tasks) { - auto series_work = Workflow::create_series_work(task, nullptr); + auto *series_work = Workflow::create_series_work(task, nullptr); parallel_work->add_series(series_work); } From b2ebc555e920cde0e258e76b7d411c5b9237f203 Mon Sep 17 00:00:00 2001 From: xiehan <52160700+Barenboim@users.noreply.github.com> Date: Tue, 10 Nov 2020 00:44:35 +0800 Subject: [PATCH 2/2] Update SeriesWork (#149) * add Workflow::unset_last_task() * fix comments Co-authored-by: XieHan --- src/factory/WFGraphTask.cc | 2 +- src/factory/Workflow.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/factory/WFGraphTask.cc b/src/factory/WFGraphTask.cc index 1fec7324..dc2e95da 100644 --- a/src/factory/WFGraphTask.cc +++ b/src/factory/WFGraphTask.cc @@ -86,7 +86,7 @@ WFGraphTask::~WFGraphTask() for (i = 0; i < this->parallel->size(); i++) { series = const_cast(this->parallel->series_at(i)); - series->set_last_task(new WFGenericTask); + series->unset_last_task(); } this->parallel->dismiss(); diff --git a/src/factory/Workflow.h b/src/factory/Workflow.h index b16b9aaa..855751d3 100644 --- a/src/factory/Workflow.h +++ b/src/factory/Workflow.h @@ -105,7 +105,7 @@ public: } public: - /* pop() and set_task_task() are intended for framework providers only. */ + /* The next 3 methods are intended for task implementations only. */ SubTask *pop(); void set_last_task(SubTask *last) @@ -114,6 +114,8 @@ public: this->last = last; } + void unset_last_task() { this->last = NULL; } + protected: void *context; series_callback_t callback;