添加多线程共享内存示例代码

Signed-off-by: haoxiaohui <haoxiaohui1@huawei.com>

# Conflicts:
#	code/Performance/PerformanceLibrary/build-profile.json5
#	code/Performance/PerformanceLibrary/product/phone/entry/oh-package.json5
#	code/Performance/PerformanceLibrary/product/phone/entry/src/main/ets/model/MockData.ets
#	code/Performance/PerformanceLibrary/product/phone/entry/src/main/resources/base/profile/main_pages.json
This commit is contained in:
haoxiaohui 2023-12-26 10:11:53 +08:00
parent 33a237fe90
commit a8bd8d1ff6
23 changed files with 820 additions and 5 deletions

View File

@ -21,12 +21,13 @@
"name": "default",
"signingConfig": "default",
"compileSdkVersion": 10,
"compatibleSdkVersion": 10
"compatibleSdkVersion": 10,
"targetSdkVersion": 10
}
],
"buildModeSet": [
{
"name": "debug",
"name": "debug"
},
{
"name": "release"
@ -81,6 +82,18 @@
{
"name": "backgroundTask",
"srcPath": "./feature/backgroundTask"
},
{
"name": "memoryShared",
"srcPath": "./feature/memoryShared",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { MemorySharedHome } from './src/main/ets/pages/MemorySharedHome';
export { AtomicsUsage } from './src/main/ets/pages/AtomicsUsage';
export { LockUsage } from './src/main/ets/pages/LockUsage';

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
}
}
}
},
],
"targets": [
{
"name": "default"
}
]
}

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

View File

@ -0,0 +1,18 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"license": "Apache-2.0",
"devDependencies": {},
"author": "",
"name": "memoryshared",
"description": "Please describe the basic information.",
"main": "MemorySharedHome.ets",
"version": "1.0.0",
"dependencies": {}
}

View File

@ -0,0 +1,109 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import taskpool from '@ohos.taskpool';
import { BusinessError } from '@ohos.base';
import logger from "../util/Logger";
@Component
export struct AtomicsUsage {
@State result: string = "";
private taskNum: number = 2;
private scroller: Scroller = new Scroller();
build() {
Row() {
Column() {
Button($r('app.string.not_use_atomics'))
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.margin({ top: 30 })
.onClick(async () => {
this.sharedArrayBufferUsage(false);
})
Button($r('app.string.use_atomics'))
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.margin({ top: 30 })
.onClick(async () => {
this.sharedArrayBufferUsage(true);
})
Text($r('app.string.result'))
.width("80%")
.fontSize(30)
.margin({ top: 30 })
.fontWeight(FontWeight.Bold)
.fontColor(Color.Blue)
Scroll(this.scroller) {
Text(this.result)
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.fontColor(Color.Blue)
}
.height("60%")
.margin({ top: 30 })
}
.width('100%')
}
.height('100%')
}
// 根据传入的值isAtomics判断是否使用原子操作
sharedArrayBufferUsage(isAtomics: boolean) {
// 创建长度为4的SharedArrayBuffer对象
let sab: SharedArrayBuffer = new SharedArrayBuffer(4);
// 由于SharedArrayBuffer是原始二进制数据缓冲区无法直接使用所以这里转换为Int32Array类型进行后续操作
let int32Array: Int32Array = new Int32Array(sab);
int32Array[0] = 0;
// 创建Task对象并放入TaskGroup中执行
let taskGroup: taskpool.TaskGroup = new taskpool.TaskGroup();
for (let i = 0; i < this.taskNum; i++) {
if (isAtomics) {
taskGroup.addTask(new taskpool.Task(atomicsProcess, int32Array));
} else {
taskGroup.addTask(new taskpool.Task(normalProcess, int32Array));
}
}
taskpool.execute(taskGroup).then(() => {
// 将结果打印在Text上
this.result = this.result + "\n" + int32Array;
// 如果Scroll不在底部则滑到到底部
if (!this.scroller.isAtEnd()) {
this.scroller.scrollEdge(Edge.Bottom);
}
}).catch((e: BusinessError) => {
logger.error(e.message);
})
}
}
// 非原子操作进行10000次++
@Concurrent
function normalProcess(int32Array: Int32Array) {
for (let i = 0; i < 10000; i++) {
int32Array[0]++;
}
}
// 原子操作进行10000次++
@Concurrent
function atomicsProcess(int32Array: Int32Array) {
for (let i = 0; i < 10000; i++) {
Atomics.add(int32Array, 0, 1);
}
}

View File

@ -0,0 +1,159 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import taskpool from '@ohos.taskpool';
import fs from '@ohos.file.fs';
import { NonReentrantLock } from '../util/LockUtil';
import logger from "../util/Logger";
@Component
export struct LockUsage {
taskNum: number = 10; // 任务数,实际并行线程数依设备而定
baseDir: string = getContext().filesDir + '/TextDir'; // 文件写入的应用沙箱路径
sabInLock: SharedArrayBuffer = new SharedArrayBuffer(4); // 在主线程,初始化子线程锁标志位,所使用的共享内存
sabForLine: SharedArrayBuffer = new SharedArrayBuffer(4); // 在主线程,初始化子线程偏移位,所使用的共享内存
@State result: string = "";
loadDialogController: CustomDialogController = new CustomDialogController({
builder: Dialog(),
alignment: DialogAlignment.Center,
autoCancel: false,
customStyle: true
});
build() {
Row() {
Column() {
// 不使用锁写入的按钮
Button($r('app.string.not_use_lock'))
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.margin({ top: 30 })
.onClick(async () => {
this.startWrite(false);
})
// 使用锁写入的按钮
Button($r('app.string.use_lock'))
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.margin({ top: 30 })
.onClick(async () => {
this.startWrite(true);
})
// 运行状态说明
Text(this.result)
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.fontColor(Color.Blue)
.margin({ top: 30 })
}
.width('100%')
}
.height('100%')
}
startWrite(useLock: boolean): void {
this.loadDialogController.open();
// 指明运行状态为“写入文件开始”
this.result = getContext().resourceManager.getStringSync($r('app.string.write_file_start'));
// 初始化写入时的偏移量
let whichLineToWrite: Int32Array = new Int32Array(this.sabForLine);
Atomics.store(whichLineToWrite, 0, 0);
// 开启多线程依据偏移量指定位置写入文件
// 通过主线程的sabInLockSharedArrayBuffer初始化锁保证多线程操作同一处锁标志位
// 通过主线程的sabForLineSharedArrayBuffer初始化偏移位保证多线程操作同一处偏移位置
let taskPoolGroup: taskpool.TaskGroup = new taskpool.TaskGroup();
for (let i: number = 0; i < this.taskNum; i++) {
taskPoolGroup.addTask(new taskpool.Task(createWriteTask, this.baseDir, i, this.sabInLock, this.sabForLine, useLock));
}
taskpool.execute(taskPoolGroup).then(() => {
// 指明运行状态为“写入文件成功”
this.result = getContext().resourceManager.getStringSync($r('app.string.write_file_success'));
this.loadDialogController.close();
}).catch(() => {
// 指明运行状态为“写入文件失败”
this.result = getContext().resourceManager.getStringSync($r('app.string.write_file_failed'));
this.loadDialogController.close();
})
}
}
@Concurrent
async function createWriteTask(baseDir: string, writeText: number, sabInLock: SharedArrayBuffer, sabForLine: SharedArrayBuffer, useLock: boolean): Promise<void> {
class Option { // 写入文件时的接口方法参数类
offset: number = 0;
length: number = 0;
encoding: string = 'utf-8';
constructor(offset: number, length: number) {
this.offset = offset;
this.length = length;
}
}
// 初始化文件目录
let filePath: string | undefined = baseDir + (useLock ? "/useLock.txt" : "/unusedLock.txt");
if (!fs.accessSync(baseDir)) {
fs.mkdirSync(baseDir);
}
// 利用主线程传入的SharedArrayBuffer初始化锁
let nrl: NonReentrantLock | undefined = undefined;
if (useLock) {
// 不可重入锁
nrl = new NonReentrantLock(sabInLock);
}
// 利用主线程传入的SharedArrayBuffer初始化写入文件时的偏移量
let whichLineToWrite: Int32Array = new Int32Array(sabForLine);
let str: string = writeText + '\n';
for (let i: number = 0; i < 100; i++) {
if (useLock && nrl !== undefined) {
// 获取锁
nrl.lock();
}
// 写入文件
let file: fs.File = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
try {
fs.writeSync(file.fd, str, new Option(whichLineToWrite[0], str.length));
} catch (err) {
logger.error(`errorCode : ${err.code},errMessage : ${err.message}`);
}
fs.closeSync(file);
// 修改偏移量,指定下次写入时的位置
whichLineToWrite[0] += str.length;
if (useLock && nrl !== undefined) {
// 释放锁
nrl.unlock();
}
}
}
@CustomDialog
export struct Dialog {
controller: CustomDialogController;
build() {
Column() {
LoadingProgress()
.color(Color.White)
.width("30%")
.height("30%")
}
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Component
export struct MemorySharedHome {
build() {
Row() {
Column() {
Button($r('app.string.atomics_action'))
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.margin({ top: 30 })
.onClick(() => {
router.pushUrl({ url: 'pages/memoryShared/AtomicsUsagePage' });
})
Button($r('app.string.lock_usage'))
.width("80%")
.fontSize(30)
.fontWeight(FontWeight.Bold)
.margin({ top: 30 })
.onClick(() => {
router.pushUrl({ url: 'pages/memoryShared/LockUsagePage' });
})
}
.width('100%')
}
.height('100%')
}
}

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const UNLOCKED: number = 0;
const LOCKED_SINGLE: number = 1;
const LOCKED_MULTI: number = 2;
export class NonReentrantLock {
flag: Int32Array;
constructor(sab: SharedArrayBuffer) {
// 传入一个4bytes的SharedArrayBuffer
this.flag = new Int32Array(sab); // 其视图为只有一位的int数组1=4bytes*8/32bit
}
lock(): void {
const flag: Int32Array = this.flag;
let c: number = UNLOCKED;
// 如果flag数组的0位置当前值为UNLOCKED则改为LOCKED_SINGLE否则进入do-while循环阻塞线程
if ((c = Atomics.compareExchange(flag, 0, UNLOCKED, LOCKED_SINGLE)) !== UNLOCKED) {
do {
// 有线程拿不到锁时修改标志位为LOCKED_MULTI并使之进入睡眠阻塞状态
if (c === LOCKED_MULTI || Atomics.compareExchange(flag, 0, LOCKED_SINGLE, LOCKED_MULTI) !== UNLOCKED) {
Atomics.wait(flag, 0, LOCKED_MULTI);
}
//被唤醒的线程,如果还是没有拿到锁,就回到循环中,重新进入阻塞状态
} while ((c = Atomics.compareExchange(flag, 0, UNLOCKED, LOCKED_MULTI)) !== UNLOCKED);
}
}
tryLock(): boolean {
const flag: Int32Array = this.flag;
return Atomics.compareExchange(flag, 0, UNLOCKED, LOCKED_SINGLE) === UNLOCKED;
}
unlock(): void {
// 局部化flag保证只有获取锁的线程可以释放锁
const flag: Int32Array = this.flag;
let v0: number = Atomics.sub(flag, 0, 1);
if (v0 !== LOCKED_SINGLE) {
Atomics.store(flag, 0, UNLOCKED);
// 只唤醒在数组0的索引位置等待的其中一个线程去上方的lock()方法while条件中检测尝试获取锁
Atomics.notify(flag, 0, 1);
}
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2022-2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
const DOMAIN: number = 0xF811;
class Logger {
private prefix: string="";
private format: string = '%{public}s, %{public}s';
constructor(prefix: string) {
this.prefix = prefix;
}
debug(...args: string[]): void {
hilog.debug(DOMAIN, this.prefix, this.format, args);
}
info(...args: string[]): void {
hilog.info(DOMAIN, this.prefix, this.format, args);
}
warn(...args: string[]): void {
hilog.warn(DOMAIN, this.prefix, this.format, args);
}
error(...args: string[]): void {
hilog.error(DOMAIN, this.prefix, this.format, args);
}
}
export default new Logger('ShareMemory');

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"module": {
"name": "memoryShared",
"type": "har",
"description": "$string:module_desc",
"deviceTypes": [
"default",
"tablet"
],
}
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}

View File

@ -0,0 +1,46 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MemorySharedAbility_desc",
"value": "description"
},
{
"name": "MemorySharedAbility_label",
"value": "label"
},{
"name": "use_lock",
"value": "使用锁"
},{
"name": "not_use_lock",
"value": "不使用锁"
},{
"name": "not_use_atomics",
"value": "非原子操作"
},{
"name": "use_atomics",
"value": "原子操作"
},{
"name": "write_file_start",
"value": "写入文件开始"
},{
"name": "write_file_success",
"value": "写入文件成功"
},{
"name": "write_file_failed",
"value": "写入文件失败"
},{
"name": "lock_usage",
"value": "锁的使用"
},{
"name": "atomics_action",
"value": "原子操作对比"
},{
"name": "result",
"value": "计算结果:"
}
]
}

View File

@ -0,0 +1,47 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MemorySharedAbility_desc",
"value": "description"
},
{
"name": "MemorySharedAbility_label",
"value": "label"
},
{
"name": "use_lock",
"value": "UseLock"
},{
"name": "not_use_lock",
"value": "NotUseLock"
},{
"name": "not_use_atomics",
"value": "NotUseAtomics"
},{
"name": "use_atomics",
"value": "UseAtomics"
},{
"name": "write_file_start",
"value": "WriteFileStart"
},{
"name": "write_file_success",
"value": "WriteFileSuccess"
},{
"name": "write_file_failed",
"value": "WriteFileFailed"
},{
"name": "lock_usage",
"value": "LockUsage"
},{
"name": "atomics_action",
"value": "AtomicsAction"
},{
"name": "result",
"value": "Result:"
}
]
}

View File

@ -0,0 +1,46 @@
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "MemorySharedAbility_desc",
"value": "description"
},
{
"name": "MemorySharedAbility_label",
"value": "label"
},{
"name": "use_lock",
"value": "使用锁"
},{
"name": "not_use_lock",
"value": "不使用锁"
},{
"name": "not_use_atomics",
"value": "非原子操作"
},{
"name": "use_atomics",
"value": "原子操作"
},{
"name": "write_file_start",
"value": "写入文件开始"
},{
"name": "write_file_success",
"value": "写入文件成功"
},{
"name": "write_file_failed",
"value": "写入文件失败"
},{
"name": "lock_usage",
"value": "锁的使用"
},{
"name": "atomics_action",
"value": "原子操作对比"
},{
"name": "result",
"value": "计算结果:"
}
]
}

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"license": "",
"devDependencies": {},
@ -28,8 +29,8 @@
"@ohos/ifOrVisibility": "file:../../../feature/ifOrVisibility",
"@ohos/dynamicImport": "file:../../../feature/dynamicImport",
"@ohos/smartPerfEditor": "file:../../../feature/smartPerfEditor",
"@ohos/hiDumper": "file:../../../feature/hiDumper",
"@ohos/trace": "file:../../../feature/trace",
"@ohos/backgroundTask": "file:../../../feature/backgroundTask"
"@ohos/memoryShared": "file:../../../feature/memoryShared",
"@ohos/hiDumper": "file:../../../feature/hiDumper"
}
}

View File

@ -51,5 +51,9 @@ export let performanceTypeArray: Array<PerformanceMsg> = [
{
name: 'BackgroundTask',
uri: 'pages/backgroundTask/BackgroundTaskPage'
},
{
name: 'MemoryShared',
uri: 'pages/memoryShared/MemorySharedHomePage'
}
]

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AtomicsUsage } from '@ohos/memoryShared';
@Entry
@Component
struct AtomicsUsagePage {
build() {
Column() {
AtomicsUsage();
}
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LockUsage } from '@ohos/memoryShared';
@Entry
@Component
struct LockUsagePage {
build() {
Column() {
LockUsage();
}
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MemorySharedHome } from '@ohos/memoryShared';
@Entry
@Component
struct MemorySharedHomePage {
build() {
Column() {
MemorySharedHome();
}
}
}

View File

@ -32,6 +32,9 @@
"pages/trace/TracePage",
"pages/backgroundTask/BackgroundTaskPage",
"pages/backgroundTask/TransientTask",
"pages/backgroundTask/LongTermTask"
"pages/backgroundTask/LongTermTask",
"pages/memoryShared/MemorySharedHomePage",
"pages/memoryShared/AtomicsUsagePage",
"pages/memoryShared/LockUsagePage"
]
}