当前位置:网站首页>客户端的那些事儿
客户端的那些事儿
2022-07-15 17:14:00 【爱摸鱼的伪程序猿】
前情回顾
在上一篇博客的最后我们提到了客户端和服务端这两个在系统框架中最重要的角色,这篇博客,将从代码的结构去解析客户端的工作流程,参考文件目录:
distributedschedule_samgr_lite/samgr_client/source/remote_register.c
该文件的相关代码注释和函数介绍在之前的博客中有提及:
OpenHarmony模块二samgr_client文件下头文件和源文件解析
函数介绍
在该文件下,主要分为以下这几个函数模块,他们涉及的功能也是我们将要深度解析的功能:
SAMGR_RegisterServiceApi //远程寄存器服务应用程序编程接口
SAMGR_FindServiceApi //查找服务Api
SAMGR_RegisterSystemCapabilityApi //注册系统能力Api
SAMGR_QuerySystemCapabilityApi //查询系统功能Api
SAMGR_GetSystemCapabilitiesApi //获取系统功能Api
ClearRegistry //清除注册表
InitializeRegistry //注册表初始化
从函数中可以看到,基本上每个服务函数的构建都离不开初始化操作,而初始化操作的第一步便是判断是否需要清除注册表,所以我们就从初始化操作入手,开始分析其中的流程。
初始化操作
ClearRegistry 清除注册表
该清除操作主要分为三个流程:
①调用VECTOR_Clear函数销毁向量对象
②调用CloseLiteIpc函数关闭LiteIpc
③调用SAMGR_Free函数释放空余的内存
进行以上操作,原本含有数据的注册表的数据就已经被清除了
InitializeRegistry 注册表初始化
初始化操作主要分为两个步骤:①清除注册表;②申请一个新的空间用来填充新的数据。
第一步清除注册表用的就是上面提到的ClearRegistry函数
第二步则分为三步:
g_remoteRegister.mtx = MUTEX_InitValue(); //申请一个临时空间
g_remoteRegister.clients = VECTOR_Make((VECTOR_Key)SAMGR_GetSAName, (VECTOR_Compare)SAMGR_CompareSAName);//创建或初始化向量对象。
g_remoteRegister.endpoint = SAMGR_CreateEndpoint("ipc client", NULL); //创建一个终端
这里要注意创建终端这个函数:SAMGR_CreateEndpoint
该函数的功能是创建终端,具体步骤如下:
①申请一个临时空间(SAMGR_Malloc)
②打开LiteIpc(OpenLiteIpc)
③创建或初始化向量对象。(VECTOR_Make)
文字描述阅读起来似乎有点绕,所以我绘制了它的流程图供大家理解:
初始化操作是客户端中最基础也是最重要的操作,所有的服务都要首先进行初始化,否则会导致数据紊乱,剩下的函数我们将在下一篇进行全面分析。
欲知后事如何,请看下篇博客。
边栏推荐
- 概率沉思录:1.Plausible reasoning
- linq 实现查询字符串拼接 : And 和 OR 两种方式
- 复杂链表的复制
- The regular expression retains [content within the matching range], and then replaces [content outside the matching range]
- Deep learning loss function
- 如何通过psql导入TPC-H数据?
- C语言:代码规范浅谈&摘录(包含【华为代码规范】部分规则摘录)
- Fosai biology interprets the changes in the atmospheric environment in the first half of 2022, and VOCs control is still the key to breaking the situation
- TP5查询空的2种情况
- ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the
猜你喜欢

Operation priority of self increasing (self decreasing) operator

The characteristics and underlying principles of synchronized, as well as the state and expansion and upgrading process of locks

Debug system

MODBUS-RS485布线的8条准则

Processing and analysis of yolov3 training data

Excel import / export annotation General Edition

synchronized的特性与底层原理以及锁的状态和膨胀升级过程

TCP three handshakes and four waves diagram

布尔代数值

抽丝剥茧C语言(高阶)静态通讯录
随机推荐
Redis introduction and installation
Fosai biology interprets the changes in the atmospheric environment in the first half of 2022, and VOCs control is still the key to breaking the situation
Private cloud ranking of Tangmen concealed weapons
linq 实现动态 orderby
[interview brush 101] double pointer
LeeCode子数组异或查询
Detailed explanation of time complexity and space complexity
Ten optimization rules of Clickhouse SQL
数组中的重复数字
C语言学习第一周——C语言的历史
MAZAK手轮维修马扎克小巨人数控机床手柄操作器维修AV-EAHS-382-1
Lifecycle: the foundation of lifecycle aware components - jetpack series (1)
带图像识别的YYS连点器 V2.0
ITSM确保IT服务台敏捷性的5大实践
Eight guidelines for modbus-rs485 wiring
左旋转字符串
“智慧工厂”上线,破局传统工厂数字化转型
COMS技术
解决${pageContext.request.contextPath }无效问题
ASP. Net