#include <iostream>
#include <boost/interprocess/managed_shared_memory.hpp>
struct pos2d
{
int x;
int y;
};
using namespace std;
int main()
{
//boost::interprocess::shared_memory_object类是按照单个字节的方式读写共享内存,用起来不方便
boost::interprocess::shared_memory_object::remove("Highscore");
boost::interprocess::managed_shared_memory managed_shm(boost::interprocess::open_or_create, "Highscore", );//分配1024字节
pos2d pos = {, };
auto ptr = managed_shm.construct<pos2d>("pos2d")(pos);
std::pair<pos2d*, std::size_t> p = managed_shm.find<pos2d>("pos2d");
if (p.first) //first是对象的指针,second表示对象的个数
{
std::cout << p.first->x << p.first->y << std::endl;
std::cout << p.second << std::endl;
}
getchar();
return ;
}

boost::interprocess::shared_memory_object(1)(基本类型)的更多相关文章

  1. boost::interprocess(2)

    //doc_anonymous_mutex_shared_data.hpp #include <boost/interprocess/sync/interprocess_mutex.hpp> ...

  2. boost::interprocess::managed_shared_memory(2)(std::string)

    #include <iostream> #include <boost/interprocess/managed_shared_memory.hpp> #include < ...

  3. boost::interprocess::managed_shared_memory(2)(std::deque)

    struct shareDataEx : shareData { int index; int total_size; }; typedef managed_shared_memory::segmen ...

  4. boost::interprocess(1)

    发送端:#include <iostream> #include <windows.h> #include <string> using namespace std ...

  5. boost信号量 boost::interprocess::interprocess_semaphore的用法

    使用方法首先给信号量初始化赋值,可以根据需要设定需要的值,之前在写项目的过程中用这个控制下载的线程个数. boost::interprocess::interprocess_semaphore m_s ...

  6. Boost.Interprocess

    https://github.com/svebert/InterprocessMsg 好像消息队列

  7. Boost IPC Persistence Of Interprocess Mechanisms 例子

    下面这一段摘抄自 Boost 1_55_0 的文档,显然标注了 每一个的生命期. One of the biggest issues with interprocess communication m ...

  8. Boost:shared_memory_object --- 共享内存

    什么是共享内存 共享内存是最快速的进程间通信机制.操作系统在几个进程的地址空间上映射一段内存,然后这几个进程可以在不需要调用操作系统函数的情况下在那段内存上进行读/写操作.但是,在进程读写共享内存时, ...

  9. boost进程间通信经常使用开发一篇全(消息队列,共享内存,信号)

    本文概要: 敏捷开发大家想必知道并且评价甚高,缩短开发周期,提高开发质量.将大project独立为不同的小app开发,整个开发过程,程序可用可測,所以提高了总体的质量.基于这样的开发模式和开发理念,进 ...

随机推荐

  1. javascript删除数组中的某个元素-----拓展Array 原型方法

    Array.prototype.remove = function (dx) { if(isNaN(dx) || dx > this.length) { return false; } var  ...

  2. STM32关总中断的语句

    __set_PRIMASK();//关总中断 /************ **********/ __set_PRIMASK();//开总中断

  3. 服务发现与负载均衡 dubbo zk原理

    服务发现与负载均衡 拓展阅读 : dubbo 原理概念图 2016-03-03 杜亦舒 性能与架构 性能与架构 性能与架构 微信号 yogoup 功能介绍 网站性能提升与架构设计 内容整理自文章“实施 ...

  4. DataURL与File,Blob,canvas对象之间的互相转换的Javascript (未完)

    canvas转换为dataURL (从canvas获取dataURL) var dataurl = canvas.toDataURL('image/png'); var dataurl2 = canv ...

  5. 浏览器 UserAgent

    IE Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; .NET C ...

  6. ML中Boosting和Bagging的比較

    说到ML中Boosting和Bagging,他们属于的是ML中的集成学习,集成学习法(Ensemble Learning) ①  将多个分类方法聚集在一起.以提高分类的准确率. (这些算法能够是不同的 ...

  7. Tokyo Tyrant(TTServer)系列(六)-数据丢失谁的错

    ,false,1,100);$mem->addServer ("127.9.9.1",1978,false,1,100);$start=microtime(true);for ...

  8. windows server 2003中端口默认不能使用问题

    问题:在windows server 2003中IIS6.0新建站点,给了一个新端口(非80),然后配置好后不能访问 解决方案:系统内置防火墙需要添加对应端口,如下图:     即解决.

  9. Error: Could not find or load main class org.apache.flume.tools.GetJavaProperty

    问题: [root@master conf]# flume-ng version Error: Could not find or load main class org.apache.flume.t ...

  10. [svc]linux常用手头命令-md版-2017年11月12日 12:31:56

    相关代码 curl命令-网站如果3次不是200或301则报警 curl -o /dev/null -s -w "%{http_code}" baidu.com -k/--insec ...