| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 35 | 32 | ||
| entry/ | 06-May-2025 | - | 743 | 638 | ||
| hvigor/ | 06-May-2025 | - | 38 | 36 | ||
| screenshots/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 133 | 12 | 12 | |
| README.md | D | 06-May-2025 | 3.1 KiB | 78 | 56 | |
| build-profile.json5 | D | 06-May-2025 | 1.4 KiB | 58 | 57 | |
| code-linter.json5 | D | 06-May-2025 | 958 | 35 | 34 | |
| hvigorfile.ts | D | 06-May-2025 | 843 | 22 | 5 | |
| oh-package.json5 | D | 06-May-2025 | 834 | 26 | 24 | |
| ohosTest.md | D | 06-May-2025 | 555 | 8 | 6 |
README.md
1# ArkTS C++线程间数据共享场景 2 3### 介绍 4 5当应用在C++层进行多线程的并发计算时,因为ArkTS的API需要在ArkTS的环境执行,为了避免在非UI主线程每次回调等待UI主线程ArkTS环境中执行的API调用结果,需要在这些C++线程上创建ArkTS执行环境和直接调用API,并且可能需要在C++线程之间对Sendable对象进行共享和操作。 6 7为了支持此类场景,需要实现在C++线程上创建调用ArkTS的能力,其次还需要对Sendable对象进行多线程共享和操作。 8 9该工程中展示的代码详细描述可查如下链接: 10 11- [C++线程间数据共享场景](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/native-interthread-shared.md) 12 13### 效果预览 14 15| 首页 | 执行结果 | 16| :----------------------------------------------------------: | :----------------------------------------------------------: | 17| <img src="./screenshots/NativeInterthreadShared_1.png" style="zoom:33%;" /> | <img src="./screenshots/NativeInterthreadShared_2.png" style="zoom:33%;" /> | 18 19### 使用说明 20 211. 在主界面,可以点击hello world,开始执行。 222. 执行结果会即时反馈在屏幕中央。 23 24### 工程目录 25 26``` 27entry/src 28 ├──main 29 │ ├── cpp 30 │ │ ├── CMakeLists.txt 31 │ │ ├── napi_init.cpp // Naitve实现加载ArkTS模块的能力示例代码 32 │ │ ├── types 33 │ │ │ ├── libentry 34 │ │ │ │ ├── Index.d.ts // 暴露接口 35 │ │ │ │ ├── oh-package.json5 36 │ ├── ets 37 │ │ ├── entryability 38 │ │ │ ├── EntryAbility.ets 39 │ │ ├── entrybackupability 40 │ │ │ ├── EntryBackupAbility.ets 41 │ │ ├── pages 42 │ │ ├── Index.ets // UI主线程发起调用示例代码 43 │ │ ├── SendableObjTest.ets // ArkTS文件定义示例代码 44 │ ├── module.json5 45 │ └── resources 46 ├── ohosTest 47 │ ├── ets 48 │ │ ├── test 49 │ │ ├── Ability.test.ets // 自动化测试代码 50``` 51 52### 相关权限 53 54不涉及。 55 56### 依赖s 57 58不涉及。 59 60### 约束与限制 61 621.本示例仅支持标准系统上运行, 支持设备:RK3568。 63 642.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。 65 663.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。 67 68### 下载 69 70如需单独下载本工程,执行如下命令: 71 72```` 73git init 74git config core.sparsecheckout true 75echo code/DocsSample/ArkTS/ArkTsConcurrent/ApplicationMultithreadingDevelopment/NativeInterthreadShared > .git/info/sparse-checkout 76git remote add origin https://gitee.com/openharmony/applications_app_samples.git 77git pull origin master 78````