From f25dce0573071578cb733584df6ba5384242585f Mon Sep 17 00:00:00 2001 From: lloyd <754415+llince@user.noreply.gitee.com> Date: Thu, 27 Feb 2025 15:50:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9F=BA=E4=BA=8ENative=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=BC=80=E5=8F=91=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E7=BA=BF=E7=A8=8B=E9=97=B4=E9=80=9A=E4=BF=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=91=E6=9B=B4=E6=96=B0=E7=BA=A6=E6=9D=9F=E4=B8=8E?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/README.en.md b/README.en.md index 6eb008b..b65a73e 100644 --- a/README.en.md +++ b/README.en.md @@ -9,6 +9,7 @@ This sample uses the producer-consumer pattern to illustrate the development of ![synchronized_operation](screenshots/device/readme.en.png) ### Project Directory + ``` ├──entry/src/main/common │ └──constans @@ -42,21 +43,17 @@ This sample uses the producer-consumer pattern to illustrate the development of - **Producer-consumer pattern**: In this model, a module generates data while another module processes it. The module that generates data is called a producer, and the module that processes data is called a consumer. In this sample, the native side implements the producer-consumer pattern using key features such as C++ threads, semaphores, and condition variables. A producer thread searches for the target file path from the string array and places it in a buffer queue. A consumer thread obtains the path from the buffer queue and returns it to the ArkTS app through thread communication. - **Communication modes between the native thread and ArkTS main thread** - + - **Multithreaded synchronous call** - In this mode, the ArkTS engine directly sends the computation result from the native code to the ArkTS app. Both the native code and the ArkTS app run on the ArkTS main thread. The producer and consumer threads use the **join()** method for synchronization. - + - **Multithreaded callback asynchronous call** - In this mode, asynchronous work items are created in the native code, and the libuv thread pool and EventLoop are used to implement asynchronous calls. The worker thread is mainly used to execute service code, and the EventLoop is mainly used to return the execution result of the worker thread to the ArkTS main thread. The ArkTS engine then uses a callback to send the computation result from the native side to the ArkTS app. - + - **Multithreaded promise asynchronous call** - This mode is similar to the callback asynchronous call. The difference is that the ArkTS engine sends the computation result from the native side to the ArkTS app through a promise object, rather than a callback. - + - **Multithreaded asynchronous call of napi_threadsafe_function** - In this mode, a thread-safe function is created in the native code, and it is called in the C++ subthread to return the ArkTS callback to the EventLoop for asynchronous processing. Unlike an asynchronous work item that passively handles an ArkTS callback, the thread-safe function can be called multiple times within a C++ subthread. In addition, the C++ subthread for the thread-safe function is created by the developer, but the worker thread in an asynchronous work item is managed by the libuv thread pool. For details about the APIs, see **NAPI description**. ### Required Permissions @@ -70,10 +67,10 @@ N/A ### Constraints -1. The sample app is supported only on Huawei phones running the standard system. +1. The sample is only supported on Huawei phones with standard systems. -2. The HarmonyOS version must be HarmonyOS NEXT Developer Beta1 or later. +2. The HarmonyOS version must be HarmonyOS 5.0.0 Release or later. -3. The DevEco Studio version must be DevEco Studio NEXT Developer Beta1 or later. +3. The DevEco Studio version must be DevEco Studio 5.0.0 Release or later. -4. The HarmonyOS SDK version must be HarmonyOS NEXT Developer Beta1 or later. +4. The HarmonyOS SDK version must be HarmonyOS 5.0.0 Release SDK or later. -- Gitee