From 04087e2679b4c2ef89c339c5a38f16a438b43a40 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Mon, 12 May 2025 11:19:44 +0800 Subject: [PATCH] fix: TaskPoolIntroduction: multi @Entry Signed-off-by: wangweiyuan --- .../ets/managers/asynchronousfunctions.ets | 73 +------------------ .../src/main/cpp/types/libentry/Index.d.ts | 2 +- .../getvm/src/main/cpp/hello.cpp | 2 +- 3 files changed, 5 insertions(+), 72 deletions(-) diff --git a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets index 7054a947b6..c98d1ccdec 100755 --- a/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets +++ b/code/DocsSample/ArkTS/ArkTsConcurrent/MultithreadedConcurrency/TaskPoolIntroduction/entry/src/main/ets/managers/asynchronousfunctions.ets @@ -76,9 +76,9 @@ struct Index { .fontWeight(FontWeight.Bold) .onClick(() => { testConcurrentFunc(); - // [StartExclude update_message_on_success] + // [StartExclude concurrent_taskpool_async_promise_usage] this.message = 'success'; - // [EndExclude update_message_on_success] + // [EndExclude concurrent_taskpool_async_promise_usage] }) } .width('100%') @@ -86,71 +86,4 @@ struct Index { .height('100%') } } -// [End concurrent_taskpool_async_promise_usage] - - - - -import { BusinessError } from '@kit.BasicServicesKit'; - -// Start和Ende成对出现验证 -// [Start test-promise_async_operation] -const promise: Promise = new Promise((resolve: Function, reject: Function) => { - setTimeout(() => { - const randomNumber: number = Math.random(); - if (randomNumber > 0.5) { - resolve(randomNumber); - } else { - reject(new Error('Random number is too small')); - } - }, 1000); -}) -// [End promise_async_operation] - -promise.then((result: number) => { - console.info(`Random number is ${result}`); -}).catch((error: BusinessError) => { - console.error(error.message); -}); - -// StartExclude 和EndExclude成对出现验证 -// [Start test-async_await_sync_operation] -async function myAsyncFunction(): Promise { - const result: string = await new Promise((resolve: Function) => { - // [StartExclude test-timeout] - setTimeout(() => { - resolve('Hello, world!'); - }, 3000); - // [EndExclude timeout] - }); - console.info(result); // 输出: Hello, world! - return result; -} - -@Entry -@Component -struct PromiseAsyncAwait { - @State message: string = 'Hello World'; - - build() { - Row() { - Column() { - Text(this.message) - // StartExclude test-update_message_on_success - .fontSize(50) - .fontWeight(FontWeight.Bold) - // [EndExclude test-update_message_on_success] - .onClick(async () => { - let res = await myAsyncFunction(); - console.info('res is: ' + res); - // [StartExclude test1-update_message_on_success] - this.message = 'success'; - // EndExclude test1-update_message_on_success - }) - } - .width('100%') - } - .height('100%') - } -} -// [End test-async_await_sync_operation] +// [End concurrent_taskpool_async_promise_usage] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts index 42dfbbb7ea..0368d3ca46 100755 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts +++ b/code/DocsSample/ArkTs/JSVMAPI/JsvmProcess/entry/src/main/cpp/types/libentry/Index.d.ts @@ -15,4 +15,4 @@ // [Start export_native] export const runTest: () => void; -// [End export_native] +// [End export_native] \ No newline at end of file diff --git a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp index fb75793a57..d2502f321f 100755 --- a/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp +++ b/code/DocsSample/ArkTs/JSVMAPI/JsvmUsageGuide/UsageInstructionsTwo/getvm/src/main/cpp/hello.cpp @@ -90,7 +90,7 @@ static JSVM_PropertyDescriptor descriptor[] = { }; const char *SRC_CALL_NATIVE = R"JS(getVM())JS"; -// [EndExclude oh_jsvm_get_vm] +// [End oh_jsvm_get_vm] static int32_t TestJSVM() { -- Gitee