一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)的C++公共基礎(chǔ)類庫(kù)案例:Semaphore

福州市凌睿智捷電子有限公司 ? 2025-02-10 18:08 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

1、程序簡(jiǎn)介

該程序是基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)的C++公共基礎(chǔ)類庫(kù)的線程處理:Sempahore。

本案例完成如下工作:

(1)無(wú)名信號(hào)量使用方法

定義1個(gè)無(wú)名信號(hào)量,1個(gè)供無(wú)名信號(hào)量管理的公共資源變量;

創(chuàng)建5個(gè)線程,每個(gè)線程做5次for循環(huán),for循環(huán)的內(nèi)容是獲取無(wú)名信號(hào)量,并修改公共資源變量;

(2)有名信號(hào)量使用方法

定義1個(gè)有名信號(hào)量,1個(gè)供有名信號(hào)量管理的公共資源變量;

創(chuàng)建1個(gè)線程A,通過(guò)Open獲取信號(hào)量,做5次for循環(huán),for循環(huán)的內(nèi)容是通過(guò)Wait獲取有名信號(hào)量,如果獲取成功則修改公共資源變量(即累加1),最后釋放信號(hào)量;

創(chuàng)建1個(gè)線程B,通過(guò)Open獲取信號(hào)量,做5次for循環(huán),for循環(huán)的內(nèi)容是通過(guò)TryWait獲取有名信號(hào)量,如果獲取成功則修改公共資源變量(即累加10),最后釋放信號(hào)量;

創(chuàng)建1個(gè)線程C,通過(guò)Open獲取信號(hào)量,做5次for循環(huán),for循環(huán)的內(nèi)容是通過(guò)TimedWait獲取有名信號(hào)量,如果獲取成功則修改公共資源變量(即累加100),最后釋放信號(hào)量;

2、基礎(chǔ)知識(shí)

C++公共基礎(chǔ)類庫(kù)為標(biāo)準(zhǔn)系統(tǒng)提供了一些常用的C++開(kāi)發(fā)工具類,包括:

文件、路徑、字符串相關(guān)操作的能力增強(qiáng)接口

讀寫鎖、信號(hào)量、定時(shí)器、線程增強(qiáng)及線程池等接口

安全數(shù)據(jù)容器、數(shù)據(jù)序列化等接口

各子系統(tǒng)的錯(cuò)誤碼相關(guān)定義

2.1、添加C++公共基礎(chǔ)類庫(kù)依賴

修改需調(diào)用模塊的BUILD.gn,在external_deps或deps中添加如下:

ohos_shared_library("xxxxx") { ... external_deps = [ ... # 動(dòng)態(tài)庫(kù)依賴(可選) "c_utils:utils", # 靜態(tài)庫(kù)依賴(可選) "c_utils:utilsbase", # Rust動(dòng)態(tài)庫(kù)依賴(可選) "c_utils:utils_rust", ] ...}

一般而言,我們只需要填寫"c_utils:utils"即可。

2.2、Semaphore頭文件

C++公共基礎(chǔ)類庫(kù)的Semaphore頭文件在://commonlibrary/c_utils/base/include/semaphore_ex.h

可在源代碼中添加如下:

#include

OpenHarmony信號(hào)量根據(jù)種類可以分為有名信號(hào)量和無(wú)名信號(hào)量,所以命令空間如下:

(1)無(wú)名信號(hào)量命名空間

OHOS::Semaphore

(2)有名信號(hào)量命名空間

OHOS::NamedSemaphore

2.3、OHOS::Samaphore接口說(shuō)明

Semaphore為無(wú)名信號(hào)量。

2.3.1、Samaphore

構(gòu)造函數(shù), 構(gòu)造一個(gè)Samaphore對(duì)象。

Semaphore(int value = 1);

參數(shù)說(shuō)明:

參數(shù)名稱類型參數(shù)說(shuō)明
valueint信號(hào)量當(dāng)前資源數(shù)量

2.3.2、~Semaphore

析構(gòu)函數(shù)。

~Semaphore();

2.3.3、Wait

等待/獲取信號(hào)量(即信號(hào)量 -1)。

void Wait();

2.3.4、Post

釋放信號(hào)量(即信號(hào)量 +1)。

void Post();

2.4、OHOS::NamedSemaphore接口說(shuō)明

NamedSemaphore為有名信號(hào)量。

2.4.1、NamedSemaphore

構(gòu)造函數(shù), 構(gòu)造NamedSemaphore對(duì)象。

NamedSemaphore(size_t size)NamedSemaphore(const std::string& name, size_t size)

參數(shù)說(shuō)明:

參數(shù)名稱類型參數(shù)說(shuō)明
namestd::string信號(hào)量名稱
sizesize_t信號(hào)量有效資源數(shù)量

2.4.2、~NamedSemaphore

析構(gòu)函數(shù)。

~NamedSemaphore();

2.4.3、Create

創(chuàng)建并初始化有名信號(hào)量。

bool Create();

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.4、Unlink

將有名信號(hào)量文件從系統(tǒng)中刪除。

bool Unlink();

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.5、Open

打開(kāi)一個(gè)已經(jīng)創(chuàng)建的有名信號(hào)量文件。

bool Open();

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.6、Close

關(guān)閉有名信號(hào)量。

bool Close();

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.7、Wait

等待/獲取信號(hào)量(信號(hào)量 -1)。

bool Wait();

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.8、TryWait

等待/獲取信號(hào)量(信號(hào)量 -1)的接口;非阻塞版。

bool TryWait();

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.9、TimedWait

等待/獲取信號(hào)量(信號(hào)量 -1);指定阻塞時(shí)間版。

bool TimedWait(const struct timespec& ts);

參數(shù)說(shuō)明:

參數(shù)名稱類型參數(shù)說(shuō)明
tsstruct timespec絕對(duì)時(shí)間。注意:ts是utc時(shí)間,不是相對(duì)時(shí)間。

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.10、Post

釋放信號(hào)量(信號(hào)量 +1)。

bool Post();

返回值說(shuō)明:

類型返回值說(shuō)明
booltrue表示成功,false表示失敗

2.4.10、GetValue

獲取信號(hào)的值。

int GetValue() const;

返回值說(shuō)明:

類型返回值說(shuō)明
int返回當(dāng)前信號(hào)量的值

3、程序解析

3.1、創(chuàng)建編譯引導(dǎo)

在//vendor/lockzhiner/rk3568/samples/BUILD.gn文件添加一行編譯引導(dǎo)語(yǔ)句。

import("http://build/ohos.gni")
group("samples") { deps = [ "a24_utils_semaphore:utils_semaphore", # 添加該行 ]}

"a24_utils_semaphore:utils_semaphore",該行語(yǔ)句表示引入?yún)⑴c編譯。

3.2、創(chuàng)建編譯項(xiàng)目

創(chuàng)建a24_utils_semaphore目錄,并添加如下文件:

a24_utils_semaphore├── utils_name_semaphore.cpp # 有名信號(hào)量案例├── utils_noname_semaphore.cpp # 無(wú)名信號(hào)量案例├── BUILD.gn # GN文件

3.3、創(chuàng)建BUILD.gn

編輯BUILD.gn文件。

添加2個(gè)可執(zhí)行程序,分別是:

utils_noname_semaphore:無(wú)名信號(hào)量使用案例

utils_name_semaphore:有名信號(hào)量使用案例

import("http://build/ohos.gni")
ohos_executable("utils_noname_semaphore") { sources = [ "utils_noname_semaphore.cpp" ] include_dirs = [ "http://commonlibrary/c_utils/base/include", "http://commonlibrary/c_utils/base:utils", "http://third_party/googletest:gtest_main", "http://third_party/googletest/googletest/include", ] external_deps = [ "c_utils:utils" ] part_name = "product_rk3568" install_enable = true}
ohos_executable("utils_name_semaphore") { sources = [ "utils_name_semaphore.cpp" ] include_dirs = [ "http://commonlibrary/c_utils/base/include", "http://commonlibrary/c_utils/base:utils", "http://third_party/googletest:gtest_main", "http://third_party/googletest/googletest/include", ] external_deps = [ "c_utils:utils" ] part_name = "product_rk3568" install_enable = true}
group("utils_semaphore") { deps = [ ":utils_noname_semaphore", ":utils_name_semaphore", ]}

注意:

(1)BUILD.gn中所有的TAB鍵必須轉(zhuǎn)化為空格,否則會(huì)報(bào)錯(cuò)。如果自己不知道如何規(guī)范化,可以:

# 安裝gn工具sudo apt-get install ninja-buildsudo apt install generate-ninja# 規(guī)范化BUILD.gngn format BUILD.gn

3.4、無(wú)名信號(hào)量使用案例

3.4.1、添加信號(hào)量頭文件

#include

3.4.2、創(chuàng)建無(wú)名信號(hào)量以及公共資源變量

static int m_count = 0; // 公共資源變量static OHOS::Semaphore m_sem(1); // 無(wú)名信號(hào)量

3.4.3、創(chuàng)建線程池

OHOS::ThreadPoolthreads("noname_semaphore_threads");

3.4.4、設(shè)置線程池

OHOS::ThreadPool threads("noname_semaphore_threads");

3.4.5、啟動(dòng)線程

for (int i = 0; i < threads_start; i++) { string str_name = "thread_" + to_string(i); auto task = std::bind(func, str_name); threads.AddTask(task); sleep(1);}

3.4.6、編寫子線程代碼

循環(huán)5次,每次循環(huán)調(diào)用信號(hào)量Wait()等待獲取信號(hào)量。如果獲取信號(hào)量后,將公共資源變量累加,調(diào)用信號(hào)量Post()釋放信號(hào)量。

void func(const string &name){ for (int i = 0; i < 5; i++) { cout << name << ": Sema Wait..." << endl; m_sem.Wait(); cout << name << ": Sema Wait Successful" << endl; m_count += 1; m_sem.Post(); cout << name << ": Sema Post" << endl; sleep(1); }}

3.5、有名信號(hào)量使用案例

3.5.1、添加信號(hào)量頭文件

#include

3.5.2、創(chuàng)建有名信號(hào)量

首先定義有名信號(hào)量,然后通過(guò)Create()創(chuàng)建全局有名信號(hào)量。

int main(int argc, char **argv){ OHOS::NamedSemaphore sem(STRING_NAME_SEMAPHORE, 1); ...... if (!sem.Create()) { cout << "NamedSemaphore.Create() failed\n"; return -1; } ......}

3.5.3、創(chuàng)建線程池

通過(guò)OHOS::ThreadPool定義線程池,調(diào)用SetMaxTaskNum()設(shè)置線程池最大線程數(shù),并調(diào)用Start()設(shè)置當(dāng)前啟動(dòng)多少個(gè)線程。

int main(int argc, char **argv){ OHOS::ThreadPool threads("name_semaphore_threads"); int threads_start = 3; ...... threads.SetMaxTaskNum(128); threads.Start(threads_start); ......}

3.5.4、啟動(dòng)子線程A、B和C

int main(int argc, char **argv){ ...... // 啟動(dòng)線程A str_name = "thread_a"; auto task_a = std::bind(funcA, str_name); threads.AddTask(task_a); // 啟動(dòng)線程B str_name = "thread_b"; auto task_b = std::bind(funcB, str_name); threads.AddTask(task_b);
// 啟動(dòng)線程A str_name = "thread_c"; auto task_c = std::bind(funcC, str_name); threads.AddTask(task_c); threads.Stop(); cout << "threads stop" << endl; return 0;}

3.5.5、編寫子線程A

首先定義有名信號(hào)量,信號(hào)量數(shù)目可以隨意設(shè)置。

其次,通過(guò)Open()打開(kāi)有名信號(hào)量,可以與main()的有名信號(hào)量共享同一個(gè)信號(hào)量。

最后,通過(guò)Wait()和Post()來(lái)獲取釋放信號(hào)量。

static void funcA(const string &name){ OHOS::NamedSemaphore sem(STRING_NAME_SEMAPHORE, 1);
cout << get_curtime() << ", " << name << ": start\n";
// 打開(kāi)一個(gè)已經(jīng)創(chuàng)建的有名信號(hào)量文件 if (!sem.Open()) { cout << get_curtime() << ", " << name << ": sema open failed" << endl; return; } for (int i = 0; i < 5; i++) { cout << get_curtime() << ", " << name << ": sema wait..." << endl; sem.Wait(); cout << get_curtime() << ", " << name << ": sema wait success" << endl; m_count += 1; usleep(1000 * 1000 * 1); cout << get_curtime() << ", " << name << ": sema count = " << m_count << endl; sem.Post(); cout << get_curtime() << ", " << name << ": sema post and sleep 1 sec" << endl; sleep(1); }
cout << get_curtime() << ", " << name << ": end" << endl;}

3.5.6、編寫子線程B

首先定義有名信號(hào)量,信號(hào)量數(shù)目可以隨意設(shè)置。

其次,通過(guò)Open()打開(kāi)有名信號(hào)量,可以與main()的有名信號(hào)量共享同一個(gè)信號(hào)量。

最后,通過(guò)TryWait()和Post()來(lái)獲取釋放信號(hào)量。

static void funcB(const string &name){ OHOS::NamedSemaphore sem(STRING_NAME_SEMAPHORE, 1);
cout << get_curtime() << ", " << name << ": start\n"; // 打開(kāi)一個(gè)已經(jīng)創(chuàng)建的有名信號(hào)量文件 if (!sem.Open()) { cout << get_curtime() << ", " << name << ": sema open failed" << endl; return; }
for (int i = 0; i < 5; i++) { cout << get_curtime() << ", " << name << ": sema trywait..." << endl; if (sem.TryWait()) { cout << get_curtime() << ", " << name << ": sema trywait success" << endl; m_count += 10; usleep(1000 * 1000 * 1); cout << get_curtime() << ", " << name << ": sema count = " << m_count << endl; sem.Post(); cout << get_curtime() << ", " << name << ": sema post and sleep 1 sec" << endl; } else { cout << get_curtime() << ", " << name << ": sema tryWait failed and sleep 1 sec" << endl; } sleep(1); }
cout << get_curtime() << ", " << name << ": end" << endl;}

3.5.7、編寫子線程C

首先定義有名信號(hào)量,信號(hào)量數(shù)目可以隨意設(shè)置。

其次,通過(guò)Open()打開(kāi)有名信號(hào)量,可以與main()的有名信號(hào)量共享同一個(gè)信號(hào)量。

最后,通過(guò)TimedWait()和Post()來(lái)獲取釋放信號(hào)量。

static void funcC(const string &name){ OHOS::NamedSemaphore sem(STRING_NAME_SEMAPHORE, 1); struct timespec ts;
cout << get_curtime() << ", " << name << ": start\n";
// 打開(kāi)一個(gè)已經(jīng)創(chuàng)建的有名信號(hào)量文件 if (!sem.Open()) { cout << get_curtime() << ", " << name << ": sema open failed" << endl; return; } for (int i = 0; i < 5; i++) { clock_gettime(CLOCK_REALTIME, &ts); // 超時(shí)等待時(shí)間,1秒 ts.tv_sec += 1; cout << get_curtime() << ", " << name << ": sema timedwait 1 sec..." << endl; if (sem.TimedWait(ts)) { cout << get_curtime() << ", " << name << ": sema timedwait success" << endl; m_count += 100; usleep(1000 * 100); cout << get_curtime() << ", " << name << ": sema count = " << m_count << endl; sem.Post(); cout << get_curtime() << ", " << name << ": sema post" << endl; } else { cout << get_curtime() << ", " << name << ": sema timedwait failed and sleep 1 sec" << endl; sleep(1); } }
cout << get_curtime() << ", " << name << ": end" << endl;
}

4、編譯步驟

進(jìn)入OpenHarmony編譯環(huán)境,運(yùn)行如下命令:

hb build -f

將鏡像燒錄到開(kāi)發(fā)板中。

5、運(yùn)行結(jié)果

5.1、無(wú)名信號(hào)量

運(yùn)行結(jié)果如下:

# utils_noname_semaphorethread_0: Sema Wait...thread_0: Sema Wait Successfulthread_0: Sema Postthread_1: Sema Wait...thread_1: Sema Wait Successfulthread_1: Sema Postthread_0: Sema Wait...thread_0: Sema Wait Successfulthread_0: Sema Postthread_2: Sema Wait...thread_2: Sema Wait Successfulthread_2: Sema Postthread_0: Sema Wait...thread_0: Sema Wait Successfulthread_0: Sema Postthread_1: Sema Wait...thread_1: Sema Wait Successfulthread_1: Sema Postthread_3: Sema Wait...thread_3: Sema Wait Successfulthread_3: Sema Postthread_2: Sema Wait...thread_0: Sema Wait Successfulthread_2: Sema Wait...thread_2: Sema Postthread_1: Sema Wait...thread_0: Sema Wait Successfulthread_0: Sema Postthread_1: Sema Wait Successfulthread_1: Sema Postthread_4: Sema Wait...thread_4: Sema Wait Successfulthread_4: Sema Postthread_3: Sema Wait...thread_3: Sema Wait Successfulthread_3: Sema Postthread_2: Sema Wait...thread_2: Sema Wait Successfulthread_2: Sema Postthread_0: Sema Wait...thread_0: Sema Wait Successfulthread_0: Sema Postthread_1: Sema Wait...thread_1: Sema Wait Successfulthread_1: Sema Postthread_4: Sema Wait...thread_4: Sema Wait Successfulthread_4: Sema Postthread_3: Sema Wait...thread_3: Sema Wait Successfulthread_3: Sema Postthread_2: Sema Wait...thread_2: Sema Wait Successfulthread_2: Sema Postthread_1: Sema Wait...thread_1: Sema Wait Successfulthread_1: Sema Postthread_4: Sema Wait...thread_4: Sema Wait Successfulthread_4: Sema Postthread_3: Sema Wait...thread_3: Sema Wait Successfulthread_3: Sema Postthread_2: Sema Wait...thread_2: Sema Wait Successfulthread_2: Sema Postthread_4: Sema Wait...thread_4: Sema Wait Successfulthread_4: Sema Postthread_3: Sema Wait...thread_3: Sema Wait Successfulthread_3: Sema Postthread_4: Sema Wait...thread_4: Sema Wait Successfulthread_4: Sema Postthreads stop#

5.2、有名信號(hào)量

運(yùn)行結(jié)果如下:

# utils_name_semaphore2017-8-5 1924, thread_a: start2017-8-5 19:43:24, thread_b: start2017-8-5 19:43:24, thread_c: start2017-8-5 19:43:24, thread_a: sema wait...2017-8-5 19:43:24, thread_a: sema wait success2017-8-5 19:43:24, thread_b: sema trywait...2017-8-5 19:43:24, thread_b: sema tryWait failed and sleep 1 sec2017-8-5 19:43:24, thread_c: sema timedwait 1 sec...2017-8-5 19:43:25, thread_a: sema count = 12017-8-5 19:43:25, thread_c: sema timedwait failed and sleep 1 sec2017-8-5 19:43:25, thread_a: sema post and sleep 1 sec2017-8-5 19:43:25, thread_b: sema trywait...2017-8-5 19:43:25, thread_b: sema trywait success2017-8-5 19:43:26, thread_a: sema wait...2017-8-5 19:43:26, thread_c: sema timedwait 1 sec...2017-8-5 19:43:26, thread_b: sema count = 112017-8-5 19:43:26, thread_b: sema post and sleep 1 sec2017-8-5 19:43:26, thread_a: sema wait success2017-8-5 19:43:27, thread_c: sema timedwait failed and sleep 1 sec2017-8-5 19:43:27, thread_b: sema trywait...2017-8-5 19:43:27, thread_b: sema tryWait failed and sleep 1 sec2017-8-5 19:43:27, thread_a: sema count = 122017-8-5 19:43:27, thread_a: sema post and sleep 1 sec2017-8-5 19:43:28, thread_c: sema timedwait 1 sec...2017-8-5 19:43:28, thread_c: sema timedwait success2017-8-5 19:43:28, thread_b: sema trywait...2017-8-5 19:43:28, thread_a: sema wait...2017-8-5 19:43:28, thread_b: sema tryWait failed and sleep 1 sec2017-8-5 19:43:28, thread_c: sema count = 1122017-8-5 19:43:28, thread_c: sema post2017-8-5 19:43:28, thread_c: sema timedwait 1 sec...2017-8-5 19:43:28, thread_a: sema wait success2017-8-5 19:43:29, thread_b: sema trywait...2017-8-5 19:43:29, thread_b: sema tryWait failed and sleep 1 sec2017-8-5 19:43:29, thread_c: sema timedwait failed and sleep 1 sec2017-8-5 19:43:29, thread_a: sema count = 1132017-8-5 19:43:29, thread_a: sema post and sleep 1 sec2017-8-5 19:43:30, thread_b: sema close2017-8-5 19:43:30, thread_c: sema timedwait 1 sec...2017-8-5 19:43:30, thread_c: sema timedwait success2017-8-5 19:43:30, thread_a: sema wait...2017-8-5 19:43:31, thread_c: sema count = 2132017-8-5 19:43:31, thread_c: sema post2017-8-5 19:43:31, thread_c: sema close2017-8-5 19:43:31, thread_a: sema wait success2017-8-5 19:43:32, thread_a: sema count = 2142017-8-5 19:43:32, thread_a: sema post and sleep 1 sec2017-8-5 19:43:33, thread_a: sema wait...2017-8-5 19:43:33, thread_a: sema wait success2017-8-5 19:43:34, thread_a: sema count = 2152017-8-5 19:43:34, thread_a: sema post and sleep 1 sec2017-8-5 19:43:35, thread_a: sema closethreads stop#

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 編譯
    +關(guān)注

    關(guān)注

    0

    文章

    676

    瀏覽量

    33867
  • 線程
    +關(guān)注

    關(guān)注

    0

    文章

    508

    瀏覽量

    20130
  • OpenHarmony
    +關(guān)注

    關(guān)注

    29

    文章

    3847

    瀏覽量

    18344
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:ThreadPoll

    1、程序簡(jiǎn)介該程序是基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)的線程池處理:Thre
    的頭像 發(fā)表于 02-10 18:09 ?330次閱讀
    基于<b class='flag-5'>OpenHarmony</b><b class='flag-5'>標(biāo)準(zhǔn)系統(tǒng)</b>的<b class='flag-5'>C++</b><b class='flag-5'>公共</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>案例:ThreadPoll

    基于ArkTS語(yǔ)言的OpenHarmony APP應(yīng)用開(kāi)發(fā):HelloOpenharmony

    1、程序簡(jiǎn)介該程序是基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)編寫的UI應(yīng)用:HelloOpenHarmony。本案例是基于API9接口開(kāi)發(fā)。本案例已在O
    的頭像 發(fā)表于 09-15 08:09 ?809次閱讀
    基于ArkTS語(yǔ)言的<b class='flag-5'>OpenHarmony</b> APP應(yīng)用開(kāi)發(fā):Hello<b class='flag-5'>Openharmony</b>

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:rwlock

    1、程序簡(jiǎn)介該程序是基于OpenHarmonyC++公共基礎(chǔ)庫(kù)的讀寫鎖:rwlock。本案例主要完成如下工作:創(chuàng)建3個(gè)讀線程,每個(gè)讀線程
    的頭像 發(fā)表于 08-30 12:42 ?630次閱讀
    基于<b class='flag-5'>OpenHarmony</b><b class='flag-5'>標(biāo)準(zhǔn)系統(tǒng)</b>的<b class='flag-5'>C++</b><b class='flag-5'>公共</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>案例:rwlock

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeMap

    1、程序簡(jiǎn)介該程序是基于OpenHarmonyC++公共基礎(chǔ)庫(kù)的安全關(guān)聯(lián)容器:SafeMap。Ope
    的頭像 發(fā)表于 08-30 12:42 ?734次閱讀
    基于<b class='flag-5'>OpenHarmony</b><b class='flag-5'>標(biāo)準(zhǔn)系統(tǒng)</b>的<b class='flag-5'>C++</b><b class='flag-5'>公共</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>案例:SafeMap

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeQueue

    1、程序簡(jiǎn)介該程序是基于OpenHarmonyC++公共基礎(chǔ)庫(kù)的線程安全隊(duì)列:SafeQueue。線程安全隊(duì)列,是在dequeue的基礎(chǔ)
    的頭像 發(fā)表于 08-30 12:41 ?648次閱讀
    基于<b class='flag-5'>OpenHarmony</b><b class='flag-5'>標(biāo)準(zhǔn)系統(tǒng)</b>的<b class='flag-5'>C++</b><b class='flag-5'>公共</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>案例:SafeQueue

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeStack

    1、程序簡(jiǎn)介該程序是基于OpenHarmonyC++公共基礎(chǔ)庫(kù)的線程安全隊(duì)列:SafeQueue。線程安全隊(duì)列,是在dequeue的基礎(chǔ)
    的頭像 發(fā)表于 08-30 12:41 ?664次閱讀
    基于<b class='flag-5'>OpenHarmony</b><b class='flag-5'>標(biāo)準(zhǔn)系統(tǒng)</b>的<b class='flag-5'>C++</b><b class='flag-5'>公共</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>案例:SafeStack

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeBlockQueue

    1、程序簡(jiǎn)介該程序是基于OpenHarmonyC++公共基礎(chǔ)庫(kù)的讀寫鎖:SafeBlockQueue。線程安全阻塞隊(duì)列SafeBlock
    的頭像 發(fā)表于 08-30 12:41 ?555次閱讀
    基于<b class='flag-5'>OpenHarmony</b><b class='flag-5'>標(biāo)準(zhǔn)系統(tǒng)</b>的<b class='flag-5'>C++</b><b class='flag-5'>公共</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>案例:SafeBlockQueue

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeBlockQueue

    /samples/a29_utils_safeblockqueue 2、基礎(chǔ)知識(shí) C++公共基礎(chǔ)庫(kù)標(biāo)準(zhǔn)系統(tǒng)提供了一些常用的
    發(fā)表于 08-22 10:52

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeStack

    /a28_utils_safestack 2、基礎(chǔ)知識(shí) C++公共基礎(chǔ)庫(kù)標(biāo)準(zhǔn)系統(tǒng)提供了一些常用的C+
    發(fā)表于 08-21 14:51

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeQueue

    /a27_utils_safequeue 2、基礎(chǔ)知識(shí) C++公共基礎(chǔ)庫(kù)標(biāo)準(zhǔn)系統(tǒng)提供了一些常用的C+
    發(fā)表于 08-21 10:56

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:SafeMap

    基礎(chǔ)庫(kù)標(biāo)準(zhǔn)系統(tǒng)提供了一些常用的C++開(kāi)發(fā)工具,包括: 文件、路徑、字符串相關(guān)操作的能力增強(qiáng)接口 讀寫鎖、信號(hào)量、定時(shí)器、線程增強(qiáng)及線程
    發(fā)表于 08-20 12:00

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:rwlock

    /samples/a25_utils_rwlock 2、基礎(chǔ)知識(shí) C++公共基礎(chǔ)庫(kù)標(biāo)準(zhǔn)系統(tǒng)提供了一些常用的
    發(fā)表于 08-20 09:37

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:Semaphore

    1、程序簡(jiǎn)介 該程序是基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)的線程處理:Semp
    發(fā)表于 08-14 16:38

    OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:HelloWorld

    1、程序簡(jiǎn)介該程序是基于凌蒙派OpenHarmony-v3.2.1標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)的簡(jiǎn)
    的頭像 發(fā)表于 08-13 08:23 ?819次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>標(biāo)準(zhǔn)系統(tǒng)</b><b class='flag-5'>C++</b><b class='flag-5'>公共</b>基礎(chǔ)<b class='flag-5'>類</b><b class='flag-5'>庫(kù)</b>案例:HelloWorld

    基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)案例:ThreadPoll

    1、程序簡(jiǎn)介 該程序是基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)C++公共基礎(chǔ)庫(kù)的線程池處理:Thr
    發(fā)表于 08-12 11:42