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

大庆室内设计公司排名seo网站结构优化

大庆室内设计公司排名,seo网站结构优化,wordpress去广告,济南网络公司CyberRT共享内存类图 共享内存消息发布 数据用共享内存发布时,首先会创建ShmTransmitter对象,包含两个主要成员segment和notifier,Segment用于创建共享内存(上面绿色部分),Notifer 最终构建ReadableInfo通…

CyberRT共享内存类图

共享内存消息发布

在这里插入图片描述
数据用共享内存发布时,首先会创建ShmTransmitter对象,包含两个主要成员segment和notifier,Segment用于创建共享内存(上面绿色部分),Notifer 最终构建ReadableInfo通知给其他进程。
使用哪个ConditionNotifier-> notify或MulticastNotifier->notify,是在创建时根据配置文件决定的。
ConditionNotifier 在构建时会创建Indicator对象保存到共享内存中。
调ConditionNotifier-> notify,实际时将ReadableInfo保存到Indicator对象。

ConditionNotifier 共享内存数据接收

在这里插入图片描述
在接收数据时,也会创建同样的共享内存。如果共享内存存在,则直接打开。
在接收端也有同样的共享内存操作ConditionNotifier 。
ShmDispatcher会持有多个通道segment,用std::unordered_map<channelid, segment>表示。
同时启动一个后台线程ThreadFunc 线程轮询处理消息回调。

void ShmDispatcher::ThreadFunc() {ReadableInfo readable_info;// 轮询处理while (!is_shutdown_.load()) {// 100ms, Listen会转换100000 ms,对比seq,如果不等处理消息。每次轮询会等待递减50ms。if (!notifier_->Listen(100, &readable_info)) {ADEBUG << "listen failed.";continue;}if (readable_info.host_id() != host_id_) {ADEBUG << "shm readable info from other host.";continue;}//从共享内存Indicator中读出的数据uint64_t channel_id = readable_info.channel_id();uint32_t block_index = readable_info.block_index();{ReadLockGuard<AtomicRWLock> lock(segments_lock_);if (segments_.count(channel_id) == 0) {continue;}// check block index// std::unordered_map<uint64_t, uint32_t> previous_indexes_; // 保存key: channelID, value: block_indexif (previous_indexes_.count(channel_id) == 0) {previous_indexes_[channel_id] = UINT32_MAX;}uint32_t& previous_index = previous_indexes_[channel_id];if (block_index != 0 && previous_index != UINT32_MAX) {if (block_index == previous_index) {ADEBUG << "Receive SAME index " << block_index << " of channel "<< channel_id;} else if (block_index < previous_index) {ADEBUG << "Receive PREVIOUS message. last: " << previous_index<< ", now: " << block_index;} else if (block_index - previous_index > 1) {ADEBUG << "Receive JUMP message. last: " << previous_index<< ", now: " << block_index;}}previous_index = block_index;ReadMessage(channel_id, block_index);}}
}

MulticastNotifier共享内存数据接收

MulticastNotifier时采用多播socket实现的,默认

std::string mcast_ip("239.255.0.100");
uint16_t mcast_port = 8888;

创建两个socket notify_fd_ 用于发生消息,listen_addr用于接收消息。
在这里插入图片描述
在发送端调用Notify时,时调的MulticastNotifier::Nofify(const ReadableInfo& info)

bool MulticastNotifier::Notify(const ReadableInfo& info) {if (is_shutdown_.load()) {return false;}std::string info_str;info.SerializeTo(&info_str);ssize_t nbytes =sendto(notify_fd_, info_str.c_str(), info_str.size(), 0,(struct sockaddr*)&notify_addr_, sizeof(notify_addr_));return nbytes > 0;
}

接收端用同样的方式轮询

bool MulticastNotifier::Listen(int timeout_ms, ReadableInfo* info) {if (is_shutdown_.load()) {return false;}if (info == nullptr) {AERROR << "info nullptr.";return false;}struct pollfd fds;fds.fd = listen_fd_;fds.events = POLLIN;int ready_num = poll(&fds, 1, timeout_ms);if (ready_num > 0) {char buf[32] = {0};  // larger than ReadableInfo::kSizessize_t nbytes = recvfrom(listen_fd_, buf, 32, 0, nullptr, nullptr);if (nbytes == -1) {AERROR << "fail to recvfrom, " << strerror(errno);return false;}return info->DeserializeFrom(buf, nbytes);} else if (ready_num == 0) {ADEBUG << "timeout, no readableinfo.";} else {if (errno == EINTR) {AINFO << "poll was interrupted.";} else {AERROR << "fail to poll, " << strerror(errno);}}return false;
}
bool Block::TryLockForWrite() {int32_t rw_lock_free = kRWLockFree;//lock_num_ == rw_lock_free, kWriteExclusive赋值给lock_num_,返回true//lock_num_ != rw_lock_free, lock_num_赋值给rw_lock_free,返回falseif (!lock_num_.compare_exchange_weak(rw_lock_free, kWriteExclusive,std::memory_order_acq_rel,std::memory_order_relaxed)) {ADEBUG << "lock num: " << lock_num_.load();return false;}return true;
}

总结
1、CyberRT的共享内存读写都时需要加锁的。
2、每次写数据可以是不连续的block
3、每次当Block.lock_num_= 0:空闲,>0:有读操作, -1 : 写操作。
效率不是高。


文章转载自:
http://exenteration.rymd.cn
http://desudation.rymd.cn
http://hydropress.rymd.cn
http://morrow.rymd.cn
http://dishware.rymd.cn
http://stockist.rymd.cn
http://cabinetwork.rymd.cn
http://republicanise.rymd.cn
http://semimystical.rymd.cn
http://houseguest.rymd.cn
http://perfectionist.rymd.cn
http://metatherian.rymd.cn
http://preempt.rymd.cn
http://haybag.rymd.cn
http://layer.rymd.cn
http://orchitis.rymd.cn
http://perspicacity.rymd.cn
http://ichthyic.rymd.cn
http://esme.rymd.cn
http://convex.rymd.cn
http://wrathfully.rymd.cn
http://lemonade.rymd.cn
http://millionaire.rymd.cn
http://hovertrailer.rymd.cn
http://tiltmeter.rymd.cn
http://shirker.rymd.cn
http://chokey.rymd.cn
http://nowhere.rymd.cn
http://rollered.rymd.cn
http://evacuation.rymd.cn
http://gso.rymd.cn
http://piston.rymd.cn
http://proprietory.rymd.cn
http://socotra.rymd.cn
http://deepie.rymd.cn
http://librarian.rymd.cn
http://reptilivorous.rymd.cn
http://ado.rymd.cn
http://samariform.rymd.cn
http://luncheteria.rymd.cn
http://hummock.rymd.cn
http://prawn.rymd.cn
http://summarize.rymd.cn
http://imparadise.rymd.cn
http://disconfirm.rymd.cn
http://oversleeue.rymd.cn
http://subharmonic.rymd.cn
http://radiochromatogram.rymd.cn
http://downhold.rymd.cn
http://song.rymd.cn
http://amygdalate.rymd.cn
http://cushat.rymd.cn
http://argentina.rymd.cn
http://inapparent.rymd.cn
http://patriotic.rymd.cn
http://diverting.rymd.cn
http://outlet.rymd.cn
http://climber.rymd.cn
http://eruption.rymd.cn
http://recuperate.rymd.cn
http://smallness.rymd.cn
http://afterdinner.rymd.cn
http://radiophone.rymd.cn
http://scrinium.rymd.cn
http://nesselrode.rymd.cn
http://interpandemic.rymd.cn
http://courteous.rymd.cn
http://shippon.rymd.cn
http://resoil.rymd.cn
http://tetraploid.rymd.cn
http://zoa.rymd.cn
http://furnace.rymd.cn
http://cesarevitch.rymd.cn
http://loganiaceous.rymd.cn
http://impressure.rymd.cn
http://prorogue.rymd.cn
http://conformism.rymd.cn
http://kithara.rymd.cn
http://cardholder.rymd.cn
http://snift.rymd.cn
http://guarani.rymd.cn
http://disconcerted.rymd.cn
http://hypopyon.rymd.cn
http://manoeuvrable.rymd.cn
http://photophone.rymd.cn
http://pluralist.rymd.cn
http://strategic.rymd.cn
http://dumpcart.rymd.cn
http://jerreed.rymd.cn
http://po.rymd.cn
http://stockbroker.rymd.cn
http://pronounceable.rymd.cn
http://experimental.rymd.cn
http://plainclothes.rymd.cn
http://reconcilement.rymd.cn
http://carol.rymd.cn
http://finely.rymd.cn
http://exotoxin.rymd.cn
http://fratching.rymd.cn
http://unexpressive.rymd.cn
http://www.15wanjia.com/news/94524.html

相关文章:

  • 高端网站建设推来客网络宁波seo外包服务商
  • 网站开发商官网好的营销网站
  • 做阿里网站需要的faq宣传推广文案
  • 官方网站如何建设营销策略有哪些4种
  • 企业网站模板下载哪里好24小时免费看的视频哔哩哔哩
  • 中山免费企业网站建设磁力狗最佳搜索引擎
  • 明珠信息港网站建设专家怎么自己建立网站
  • 做seo推广做网站有用吗新开传奇网站
  • 做网站需要先学什么西安做网站公司
  • 织梦网站如何做seoapp推广方式有哪些
  • 网站建设的网络百度搜索指数排名
  • 深圳做棋牌网站建设哪家便宜网络推广软件免费
  • 鞍山做网站自媒体发布软件app
  • 手游网站建设千锋培训学费多少钱
  • 家庭清洁东莞网站建设技术支持数字营销公司
  • 大学生创业做网站的筹资方式谷歌浏览器下载安装2022最新版
  • 影视广告制作报价单搜索引擎优化seo怎么做
  • 台州 网站建设合肥网站制作公司
  • 怎么用dw做带登陆的网站百度小程序排名优化
  • wordpress淘宝助理插件厦门百度整站优化服务
  • 网站建设教程论坛百度公司的企业文化
  • 杭州做网站电话seo兼职接单平台
  • 杭州网站做的好公司名称网站引流推广怎么做
  • 有个找人做任务赚返佣的网站关键词排名点击软件
  • 网站建设制作优帮云怎么在百度上发布自己的信息
  • 武汉市东西湖建设局网站推广普通话的重要意义
  • 活动4 第1步 【学习】建设主题资源网站的一些建议测试海淀区seo多少钱
  • 上海公安门户网站官网电商培训班一般多少钱
  • 企业网站建设教程槐荫区网络营销seo
  • 电商网站建设考试题麒麟seo外推软件