!1057 内源检视优先级0308

Merge pull request !1057 from 施其昌/nei
This commit is contained in:
openharmony_ci 2022-03-11 02:20:28 +00:00 committed by Gitee
commit f3566f3acc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 54 additions and 48 deletions

View File

@ -47,8 +47,8 @@ public:
*
* @param runnable is the job to execute.
* @return an interface for revoke the task if it hasn't been invoked.
*
*/
virtual std::shared_ptr<Revocable> AsyncDispatch(const std::shared_ptr<Runnable> &runnable) override = 0;
/**
@ -59,6 +59,7 @@ public:
*/
virtual std::shared_ptr<Revocable> DelayDispatch(
const std::shared_ptr<Runnable> &runnable, long delayMs) override = 0;
/**
* Set a barrier and meanwhile a sync task that execute after all tasks finished.
* @param runnable is the job to execute after barrier.
@ -82,7 +83,6 @@ public:
* @param group related by task.
* @param runnable is the job to execute.
* @return an interface for revoke the task if it hasn't been invoked.
*
*/
virtual std::shared_ptr<Revocable> AsyncGroupDispatch(
const std::shared_ptr<Group> &group, const std::shared_ptr<Runnable> &runnable) override;
@ -183,4 +183,4 @@ private:
} // namespace AppExecFwk
} // namespace OHOS
#endif
#endif

View File

@ -14,6 +14,7 @@
*/
#ifndef OHOS_APP_DISPATCHER_GROUP_IMPL_H
#define OHOS_APP_DISPATCHER_GROUP_IMPL_H
#include <atomic>
#include <deque>
#include <mutex>
@ -29,6 +30,7 @@ namespace AppExecFwk {
class GroupImpl : public Group {
public:
GroupImpl();
~GroupImpl() = default;
/**
* Wait all tasks associated to this group to be done.

View File

@ -41,6 +41,7 @@ class ParallelTaskDispatcherBase : public BaseTaskDispatcher,
public:
ParallelTaskDispatcherBase(
TaskPriority taskPriority, std::shared_ptr<TaskExecutor> &executor, const std::string &dispatcherName);
virtual ~ParallelTaskDispatcherBase() = default;
/**
* Called when post a task to the TaskDispatcher with waiting Attention: Call
@ -118,4 +119,4 @@ private:
} // namespace AppExecFwk
} // namespace OHOS
#endif
#endif

View File

@ -81,6 +81,7 @@ public:
*
*/
std::shared_ptr<Revocable> DelayDispatch(const std::shared_ptr<Runnable> &runnable, long delayMs);
private:
ErrCode OnNewTaskIn(std::shared_ptr<Task> &task);
@ -104,6 +105,7 @@ private:
bool DoNext(bool isExhausted);
void DoWork(std::shared_ptr<Task> &task);
private:
static std::string DISPATCHER_TAG;
static std::string ASYNC_DISPATCHER_TAG;

View File

@ -74,7 +74,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_LifeCycleTest_
ptr->AsyncDispatch(runnable);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
context->Shutdown(true);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -85,11 +85,11 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_LifeCycleTest_
HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_CreateParallelDispatcherTest_001, TestSize.Level1)
{
auto name = std::string("ParallelTaskDispatcher_CreateParallelDispatcherTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<ParallelTaskDispatcher> ptr1 = CreateMtParallelTaskDispatcher(name, TaskPriority::DEFAULT);
std::shared_ptr<ParallelTaskDispatcher> ptr2 = CreateMtParallelTaskDispatcher(name, TaskPriority::DEFAULT);
EXPECT_FALSE((ptr1.get() == ptr2.get()));
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -100,7 +100,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_CreateParallel
HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_SyncDispatchTest_001, TestSize.Level1)
{
auto name = std::string("ParallelTaskDispatcher_SyncDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<ParallelTaskDispatcher> ptr = CreateMtParallelTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
EXPECT_TRUE(count.load() == 0);
@ -126,7 +126,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_SyncDispatchTe
auto time = std::chrono::milliseconds(wait);
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 2);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -194,7 +194,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_AsyncGroupDisp
EXPECT_TRUE(ptr->GroupDispatchWait(group, 1000));
std::this_thread::sleep_for(std::chrono::milliseconds(300));
EXPECT_TRUE(count.load() == 3);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -223,7 +223,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_AsyncGroupDisp
EXPECT_EQ(result, false);
auto time = std::chrono::milliseconds(600);
std::this_thread::sleep_for(time);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -256,7 +256,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_ApplyDispatchT
std::this_thread::sleep_for(time);
int index = count.fetch_add(1);
EXPECT_TRUE(index < repeatCount);
GTEST_LOG_(INFO) << name + " repeats2";
GTEST_LOG_(INFO) << (name + " repeats2");
});
ptr->ApplyDispatch(repeats2, repeatCount);

View File

@ -69,7 +69,7 @@ std::shared_ptr<SerialTaskDispatcher> SerialTaskDispatcherModuleTest::CreateMtSe
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_LifeCycleTest_001, TestSize.Level1)
{
auto name = std::string("SerialTaskDispatcher_LifeCycleTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> ptr = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
std::shared_ptr<Runnable> runnable = std::make_shared<Runnable>([&]() {
@ -80,7 +80,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_LifeCycleTest_001,
ptr->SyncDispatch(runnable);
context->Shutdown(true);
EXPECT_EQ(count.load(), 1);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -91,11 +91,11 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_LifeCycleTest_001,
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_CreateSerialDispatcherTest_001, TestSize.Level1)
{
auto name = std::string("SerialTaskDispatcher_CreateSerialDispatcherTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> ptr1 = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
std::shared_ptr<SerialTaskDispatcher> ptr2 = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
EXPECT_FALSE((ptr1.get() == ptr2.get()));
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -146,7 +146,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_SyncDispatchTest_0
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_AsyncDispatchTest_001, TestSize.Level1)
{
auto name = std::string("SerialTaskDispatcher_AsyncDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> ptr = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
long sleep1 = 200;
@ -171,7 +171,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_AsyncDispatchTest_
auto time = std::chrono::milliseconds(wait);
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 2);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -182,7 +182,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_AsyncDispatchTest_
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_AsyncDispatchTest_002, TestSize.Level1)
{
auto name = std::string("SerialTaskDispatcher_AsyncDispatchTest_002");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> ptr = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
const int total = 300;
std::atomic<int> count(0);
@ -200,7 +200,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_AsyncDispatchTest_
auto time = std::chrono::milliseconds(wait + 1000);
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == total);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -211,7 +211,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_AsyncDispatchTest_
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_001, TestSize.Level0)
{
auto name = std::string("SerialTaskDispatcher_DelayDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> dispatcher = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
int sleep1 = 2000;
@ -270,7 +270,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 3);
}
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -281,11 +281,11 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_002, TestSize.Level0)
{
auto name = std::string("SerialTaskDispatcher_DelayDispatchTest_003");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> dispatcher = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
int sleep1 = 2000;
dispatcher->DelayDispatch(nullptr, sleep1);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -296,7 +296,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_003, TestSize.Level0)
{
auto name = std::string("SerialTaskDispatcher_DelayDispatchTest_004");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> dispatcher = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
int sleep1 = -2000;
@ -323,7 +323,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 2);
}
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -334,7 +334,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_DelayDispatchTest_
HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_ApplyDispatchTest_001, TestSize.Level0)
{
auto name = std::string("SerialTaskDispatcher_ApplyDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<SerialTaskDispatcher> ptr = CreateMtSerialTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
long sleep1 = 101;
@ -361,7 +361,7 @@ HWTEST_F(SerialTaskDispatcherModuleTest, SerialTaskDispatcher_ApplyDispatchTest_
auto time = std::chrono::milliseconds(wait);
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 20);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**

View File

@ -15,11 +15,12 @@
// redefine private and protected since testcase need to invoke and test private function
#include <gtest/gtest.h>
#include "spec_task_dispatcher.h"
#include "app_log_wrapper.h"
#include "base_task_dispatcher.h"
#include "hilog_wrapper.h"
#include "task_dispatcher_context.h"
#include "task_dispatcher.h"
#include "spec_task_dispatcher.h"
using namespace testing::ext;
using namespace OHOS::AppExecFwk;
@ -101,7 +102,7 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_SyncDispatchTest_001,
HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_AsyncDispatchTest_001, TestSize.Level1)
{
auto name = std::string("SpecTaskDispatcher_AsyncDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::atomic<int> count(0);
long sleep1 = 200;
@ -127,7 +128,7 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_AsyncDispatchTest_001,
auto time = std::chrono::milliseconds(wait);
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 2);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -138,7 +139,7 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_AsyncDispatchTest_001,
HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_001, TestSize.Level0)
{
auto name = std::string("SpecTaskDispatcher_DelayDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::atomic<int> count(0);
int sleep1 = 2000;
@ -197,7 +198,7 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_001,
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 3);
}
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -208,11 +209,11 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_001,
HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_002, TestSize.Level0)
{
auto name = std::string("SpecTaskDispatcher_DelayDispatchTest_002");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
int sleep1 = 2000;
ptrSpecTaskDispatcher->DelayDispatch(std::make_shared<Runnable>(nullptr), sleep1);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -223,11 +224,11 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_002,
HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_003, TestSize.Level0)
{
auto name = std::string("SpecTaskDispatcher_DelayDispatchTest_003");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
int sleep1 = 2000;
ptrSpecTaskDispatcher->DelayDispatch(nullptr, sleep1);
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -238,7 +239,7 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_003,
HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_004, TestSize.Level0)
{
auto name = std::string("SpecTaskDispatcher_DelayDispatchTest_004");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::atomic<int> count(0);
int sleep1 = -2000;
@ -266,7 +267,7 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_004,
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 2);
}
GTEST_LOG_(INFO) << name + " end";
GTEST_LOG_(INFO) << (name + " end");
}
/**
@ -277,7 +278,7 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_DelayDispatchTest_004,
HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_ApplyDispatchTest_001, TestSize.Level0)
{
auto name = std::string("SpecTaskDispatcher_ApplyDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::atomic<int> count(0);
long sleep1 = 101;
@ -305,5 +306,5 @@ HWTEST_F(SpecTaskDispatcherModuleTest, SpecTaskDispatcher_ApplyDispatchTest_001,
auto time = std::chrono::milliseconds(wait);
std::this_thread::sleep_for(time);
EXPECT_TRUE(count.load() == 20);
GTEST_LOG_(INFO) << name + " end";
}
GTEST_LOG_(INFO) << (name + " end");
}

View File

@ -211,4 +211,4 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_ContainsAbility_002, Function
GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_ContainsAbility_002 end";
}
} // namespace AppExecFwk
}
}

View File

@ -886,4 +886,4 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseAbility_002, TestSi
EXPECT_EQ(IAbilityManager::RELEASE_CALL_ABILITY, mock_->code_);
}
} // namespace AAFwk
} // namespace OHOS
} // namespace OHOS

View File

@ -345,4 +345,4 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_016, TestS
EXPECT_EQ(IAbilityScheduler::DUMP_ABILITY_RUNNER_INNER, mock_->code_);
}
} // namespace AAFwk
} // namespace OHOS
} // namespace OHOS

View File

@ -270,4 +270,4 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_011, TestSize.Level1)
EXPECT_EQ(res, NO_ERROR);
}
} // namespace AAFwk
} // namespace OHOS
} // namespace OHOS

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -16,4 +16,4 @@
interface OHOS.IZidlTestService {
int TestIntTransaction([in] int data);
void TestStringTransaction([in] String data);
}
}