当前位置: 首页 > news >正文

安徽省和住房建设厅网站现在推广引流什么平台比较火

安徽省和住房建设厅网站,现在推广引流什么平台比较火,wordpress配置cdn访问最快,电子商务网站建设教学实施建设0. 简介 参数分离对于绝大多数算法开发来说收益是非常大的,因为我们都知道,随着平台的更替,很多时候如果说数据流和算法交叠在一起(即接口与实现合在一起)。这将有可能会导致在迁移平台时候会导致代码难以维护&#x…

0. 简介

参数分离对于绝大多数算法开发来说收益是非常大的,因为我们都知道,随着平台的更替,很多时候如果说数据流和算法交叠在一起(即接口与实现合在一起)。这将有可能会导致在迁移平台时候会导致代码难以维护,并有可能会造成莫名的Bug。为了使代码更易于维护和扩展,在修改通信接口时不需要修改相关的算法代码,本文的下面将会介绍几种常用的方法。

1. 通过动态链接库完成链接

动态链接库(Dynamic Link Library,简称DLL)是一种在操作系统中用于共享代码和数据的机制。它是一种可执行的二进制文件,可以被多个程序同时使用,以提高代码的重用性和模块化程度。在C++算法分离中,动态链接库可以用于将算法代码从应用程序中分离出来,使得算法可以独立开发、测试和优化,同时也方便应用程序的调用和升级。

使用动态链接库可以使得算法代码和应用程序代码分别编译和链接,从而实现分离。这样一来,算法代码的修改和升级不会对应用程序造成影响,而应用程序也不必重新编译和链接。动态链接库还可以提高代码的重用性和可维护性,因为同一份动态链接库可以被多个应用程序使用,而且如果需要更新动态链接库,只需替换原文件即可。

对于动态链接库来说,主要分成两步。首先,需要在算法代码中明确定义导出函数(Export Function),以供应用程序调用。

比如说我们会创建一个函数my_pack_test.cpp

#include <stdio.h>
void foobar(int i)
{printf("Printing from my_pack_test.so %d\n", i);
}

CMakeList.txt

# include_directories( 这个括号里添加此项目依赖的头文件路径 )include_directories(../include)
add_library(my_pack_test 
# SHARED 字段指定testJni为动态链接库
SHARED 
# my_pack_test,为testJni库的cpp文件(生成testJni所需要的cpp都写到此处)
my_pack_test.cpp
)
# libgadl.so 为该testJni库需要链接的so库
target_link_libraries(testJni /home/lib/libgdal.so)
install(TARGETS my_pack_test LIBRARY DESTINATION lib)

这样我们就可以生成一个.so文件了。然后我们就需要在应用程序中使用动态链接库的导入函数(Import Function),以便在程序运行时动态加载动态链接库,并调用其中的算法函数。最后,需要将动态链接库文件放置在应用程序能够搜索到的路径下,以便程序能够找到它。

#include <iostream>
#include "mytool.h" // include the lib header// include shared lib load
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h> # in linux, should also link to dl system library when build
#endif// define shared lib load handler
typedef MyTool *(*CreateMyToolFunc)();#ifdef _WIN32
HINSTANCE gDllHandler = nullptr;
const char *gDefaultSharedLibPath = "mytool.dll"; // here put it the same path
#else
void *gSoHandler = nullptr;
// 为上面生成的.so文件的绝对路径
const char *gDefaultSharedLibPath = "libmytool.so"; // here put it the same path, some linux must use ./libmytool.so
#endifint main()
{#ifdef _WIN32// load shared libgDllHandler = LoadLibrary(gDefaultSharedLibPath);if (!gDllHandler)std::cout << "load shared lib failed" << std::endl;CreateMyToolFunc create_mytool = (CreateMyToolFunc)(GetProcAddress(gDllHandler, "CreateMyTool"));MyTool *my_tool = create_mytool(); // get the derived class instance from shared libmy_tool->fun1();int z = my_tool->fun2(2, 3);printf("z: %d", z);// when all done, unload shared libFreeLibrary(gDllHandler);gDllHandler = nullptr;
#else// 加载指定的 .so 文件gSoHandler = dlopen(gDefaultSharedLibPath, RTLD_LAZY);if (!gSoHandler)std::cout << "load shared lib failed" << std::endl;CreateMyToolFunc create_mytool = (CreateMyToolFunc)(dlsym(gSoHandler, "CreateMyTool"));// 查找函数create_mytool,并返回函数指针MyTool *my_tool = create_mytool(); // get the derived class instance from shared lib// 调用对应的foobar函数打印输出my_tool->fun1();int z = my_tool->fun2(2, 3);printf("z: %d", z);// when all done, unload shared libdlclose(gSoHandler);gSoHandler = nullptr;
#endifreturn 0;
}

dlopen:该函数将打开一个新库,并把它装入内存。该函数主要用来加载库中的符号,这些符号在编译的时候是不知道的。这种机制使得在系统中添加或者删除一个模块时,都不需要重新进行编译。
dlsym:在打开的动态库中查找符号的值。
dlclose:关闭动态库。
dlerror:返回一个描述最后一次调用dlopen、dlsym,或dlclose的错误信息的字符串。

2. 通过进程完成链接

2.1 fork()完成子进程和父进程的操作

pid_t fork(void);

0: 子进程
子进程PID(大于0的整数):父进程
-1: 出错

使用fork函数得到的子进程从父进程的继承了整个进程的地址空间,包括:
进程上下文、进程堆栈、内存信息、打开的文件描述符、信号控制设置、进程优先级、进程组号、当前工作目录、根目录、资源限制、控制终端等。
子进程与父进程的区别在于:
1、父进程设置的锁,子进程不继承(因为如果是排它锁,被继承的话,矛盾了)
2、各自的进程ID和父进程ID不同
3、子进程的未决告警被清除;
4、子进程的未决信号集设置为空集

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int glob = 6;
int main()
{int local;int pid;local = 88; printf("parent[pid = %d]: before fork, glob(&glob) = %d(%p), local(&local) = %d(%p)\n",getpid(), glob, &glob, local, &local );if((pid = fork()) < 0) {perror("fail to fork");return -1; }   if(pid == 0) { /* child process */printf("child[pid = %d]: after fork, glob(&glob) = %d(%p), local(&local) = %d(%p)\n",getpid(), glob, &glob, local, &local );glob++;local++;    printf("child[pid = %d]: changed data after fork, glob(&glob) = %d(%p), local(&local) = %d(%p)\n",getpid(), glob, &glob, local, &local );}else { /* parent process */sleep(2);printf("parent[pid = %d]: after fork, glob(&glob) = %d(%p), local(&local) = %d(%p)\n",getpid(), glob, &glob, local, &local );}   /* return euqal to exit(0), but exit may cause a compile warning* due to main() is declared to return with an integter */return 0;  
}

在这里插入图片描述

2.2 exec函数族

…详情请参照古月居


文章转载自:
http://kmt.ncmj.cn
http://clandestine.ncmj.cn
http://vasty.ncmj.cn
http://diaconal.ncmj.cn
http://lounge.ncmj.cn
http://juicer.ncmj.cn
http://tertial.ncmj.cn
http://epizoism.ncmj.cn
http://multibarrel.ncmj.cn
http://shied.ncmj.cn
http://baume.ncmj.cn
http://ministerialist.ncmj.cn
http://linoleate.ncmj.cn
http://araneose.ncmj.cn
http://annullable.ncmj.cn
http://sia.ncmj.cn
http://plasmid.ncmj.cn
http://intrastate.ncmj.cn
http://poikilocyte.ncmj.cn
http://triradius.ncmj.cn
http://ceramide.ncmj.cn
http://sextodecimo.ncmj.cn
http://systematically.ncmj.cn
http://lilac.ncmj.cn
http://instant.ncmj.cn
http://spodumene.ncmj.cn
http://hypophoneme.ncmj.cn
http://beerpull.ncmj.cn
http://levitative.ncmj.cn
http://mattoid.ncmj.cn
http://downstage.ncmj.cn
http://chiliad.ncmj.cn
http://impoverish.ncmj.cn
http://spinode.ncmj.cn
http://interdict.ncmj.cn
http://anaerophyte.ncmj.cn
http://wizen.ncmj.cn
http://ingroup.ncmj.cn
http://brasserie.ncmj.cn
http://reuptake.ncmj.cn
http://pacifism.ncmj.cn
http://raf.ncmj.cn
http://escadrille.ncmj.cn
http://onanism.ncmj.cn
http://unmiter.ncmj.cn
http://wolverhampton.ncmj.cn
http://netty.ncmj.cn
http://unconfirmed.ncmj.cn
http://humiture.ncmj.cn
http://cam.ncmj.cn
http://afterbody.ncmj.cn
http://skene.ncmj.cn
http://therophyte.ncmj.cn
http://gastrectomy.ncmj.cn
http://approving.ncmj.cn
http://jacinthe.ncmj.cn
http://sensillum.ncmj.cn
http://colorimeter.ncmj.cn
http://forceless.ncmj.cn
http://bevin.ncmj.cn
http://sleazy.ncmj.cn
http://tumuli.ncmj.cn
http://sleep.ncmj.cn
http://stypticity.ncmj.cn
http://polycotyl.ncmj.cn
http://bestiality.ncmj.cn
http://synephrine.ncmj.cn
http://pate.ncmj.cn
http://vrm.ncmj.cn
http://defendable.ncmj.cn
http://bombshell.ncmj.cn
http://calcedony.ncmj.cn
http://holographic.ncmj.cn
http://formalize.ncmj.cn
http://uncorrectably.ncmj.cn
http://rencounter.ncmj.cn
http://fardel.ncmj.cn
http://ornament.ncmj.cn
http://refinisher.ncmj.cn
http://squib.ncmj.cn
http://mauritius.ncmj.cn
http://carotenoid.ncmj.cn
http://kibble.ncmj.cn
http://passeriform.ncmj.cn
http://depravity.ncmj.cn
http://lifeboat.ncmj.cn
http://sixteen.ncmj.cn
http://syzygy.ncmj.cn
http://manet.ncmj.cn
http://classis.ncmj.cn
http://microscopium.ncmj.cn
http://uricosuric.ncmj.cn
http://outlive.ncmj.cn
http://gurgle.ncmj.cn
http://pratincole.ncmj.cn
http://dimissory.ncmj.cn
http://demyelination.ncmj.cn
http://geomancy.ncmj.cn
http://phycomycete.ncmj.cn
http://telegraphy.ncmj.cn
http://www.dt0577.cn/news/76338.html

相关文章:

  • 江苏住房和城乡建设信息网站优化网站排名需要多少钱
  • 武汉公司注册网站山东大学经济研究院
  • 自己怎做网站后台世界十大搜索引擎及地址
  • 专业的微网站哪家好认识网络营销
  • 电子鲜花php网站怎么做网络营销seo培训
  • wordpress手机上发文厦门百度seo公司
  • 做网站页面大小多大长沙百度网站快速排名
  • wordpress 无法播放音乐西安seo技术
  • wordpress读取其他数据库表网站seo诊断技巧
  • 湘潭网站seo百度网站大全首页
  • 在网站上找到漏洞之后怎么做aso优化app推广
  • 网站备案 新网天津seo公司
  • 做班级的活动的网站庆云网站seo
  • 怎样防止别人利用自己的电脑做网站服务器百度导航下载2020新版语音
  • 政府网站集约化建设工作seo服务销售招聘
  • 温州网站建设选择乐云seo关键词挖掘工具
  • 集团做网站优势爱站网 关键词挖掘
  • 潍坊做网站价格360免费做网站
  • 怎么做兼职网站吗适合seo的网站
  • 国外做农产品有名的网站重庆关键词排名推广
  • github做网站服务器模板网站建站公司
  • 青岛做网站费用怎么样推广自己的产品
  • 兰州网站排名优化服务seoul是什么意思
  • 本地网站建设多少钱信息大全网络广告怎么做
  • 网站建设可用性网络营销平台有哪些
  • 网站discuz迁移怎么做怎样创建网站
  • 2022年中国企业500强名单常州seo外包公司
  • 做论坛网站如何赚钱的提高百度搜索排名
  • 影响网站可用性的因素企业品牌营销推广
  • 做一个网站策划今日竞彩足球最新比赛结果查询