mirror of
https://github.com/openharmony/ace_engine_lite.git
synced 2026-07-21 08:55:21 -04:00
Description: fix async work task crash issue
IssueNo: I4CGY3 Feature or Bugfix: Feature Binary Source:No Signed-off-by: jiadexiang <jiadexiang@huawei.com>
This commit is contained in:
@@ -98,6 +98,7 @@ void AsyncTaskManager::Callback()
|
||||
|
||||
while (head_ != nullptr) {
|
||||
AsyncTask *task = head_;
|
||||
task->isRunning = true;
|
||||
task->handler(task->data);
|
||||
if (head_ == tail_) {
|
||||
tail_ = nullptr;
|
||||
@@ -129,6 +130,7 @@ uint16_t AsyncTaskManager::Dispatch(AsyncTaskHandler handler, void *data, const
|
||||
task->data = data;
|
||||
task->id = (++uniqueTaskID_);
|
||||
task->context = context;
|
||||
task->isRunning = false;
|
||||
task->next = nullptr;
|
||||
if (head_ == nullptr) {
|
||||
head_ = task;
|
||||
@@ -151,7 +153,7 @@ void AsyncTaskManager::Cancel(uint16_t taskID)
|
||||
AsyncTask *node = head_;
|
||||
AsyncTask *prev = nullptr;
|
||||
while (node != nullptr) {
|
||||
if (node->id == taskID) {
|
||||
if (node->id == taskID && !(node->isRunning)) {
|
||||
if (prev == nullptr) {
|
||||
head_ = head_->next;
|
||||
} else {
|
||||
@@ -182,7 +184,7 @@ void AsyncTaskManager::CancelWithContext(const void *context)
|
||||
AsyncTask *next = nullptr;
|
||||
while (node != nullptr) {
|
||||
next = node->next;
|
||||
if (node->context == context) {
|
||||
if ((node->context == context) && !(node->isRunning)) {
|
||||
if (prev == nullptr) {
|
||||
head_ = head_->next;
|
||||
} else {
|
||||
|
||||
@@ -36,6 +36,7 @@ struct AsyncTask final : public MemoryHeap {
|
||||
AsyncTaskHandler handler;
|
||||
void *data;
|
||||
AsyncTask *next;
|
||||
bool isRunning;
|
||||
};
|
||||
|
||||
constexpr uint16_t DISPATCH_FAILURE = 0;
|
||||
|
||||
@@ -181,8 +181,6 @@ INCLUDEPATH += \
|
||||
$${ROOT_PATH}/foundation/aafwk/aafwk_lite/interfaces/kits/ability_lite \
|
||||
$${ROOT_PATH}/foundation/aafwk/aafwk_lite/interfaces/kits/want_lite \
|
||||
$${ROOT_PATH}/foundation/aafwk/aafwk_lite/interfaces/innerkits/abilitymgr_lite \
|
||||
$${ROOT_PATH}/foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite \
|
||||
$${ROOT_PATH}/foundation/appexecfwk/appexecfwk_lite/utils/bundle_lite \
|
||||
$${ROOT_PATH}/foundation/communication/ipc_lite/liteipc/include \
|
||||
$${ROOT_PATH}/third_party/bounds_checking_function/include \
|
||||
$${ROOT_PATH}/foundation/ace/ace_engine_lite/interfaces/innerkits/builtin/async \
|
||||
|
||||
Reference in New Issue
Block a user