#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. 6. Laravel5学习笔记:IOC/DI的理解

    介绍 IOC 控制反转 Inversion of Control 依赖关系的转移 依赖抽象而非实践 DI 依赖注入 Dependency Injection 不必自己在代码中维护对象的依赖 容器自己主 ...

  2. 安装Redmine 2.3.0(Ubuntu 12.04 Server)

    怀揣着为中小企业量身定做一整套开源软件解决方案的梦想开始了一个网站的搭建.http://osssme.org/ 安装Redmine 2.3.0(Ubuntu 12.04 Server) 翻译源\参考源 ...

  3. 域对象的引用,ActionContext 和ServletActionContext类的使用

    ActionContext 获取 域引用的map ServletActionContext获取具体域对象 //域范围 ActionContext ac = ActionContext.getConte ...

  4. Asp.Net MVC之防止用户注入脚本参数

    假设有一个Controller,代码如下: public string Browse(string genre) { string message = "Store.Browse, Genr ...

  5. poj_2773

    题目的愿意非常easy.给你一个n,求在升序排列的情况下,第k个与之相互素的数. 解法:首先我们要知道gcd(b×t+a,b)=gcd(a.b),那么接下来就非常easy了.全部与之互素的数都是以ph ...

  6. python-循环while

    while 只要…条件成立,就一直做…. for 循环会在可迭代的序列被穷尽的时候停止,while 则是在条件不成立的时候停止,因此 while 的作用概括成一句话就是:只要…条件成立,就一直做…. ...

  7. 【转载】使用Exp和Expdp导出数据的性能对比与优化

    转自:http://blog.itpub.net/117319/viewspace-1410931/ 序:这方面的文章虽然很多人写过,但是结合实际进行详细的对比分析的不多,这里,结合所在公司的行业,进 ...

  8. printf函数对参数的计算顺序

    没想到啊,没想到: printf函数对参数的计算顺序是从右往左的! 我不禁想问一句,这么坑爹的事情,书里居然没有写过.还是我看书不仔细,没有找到?(回头,在自己翻翻那本c语言编程) 于是下面的程序结果 ...

  9. 阿里大鱼短信接口(Python3版)

    近期由于须要用到短信接口,选型的的结果是用阿里大鱼的短信服务,然而淘宝开放平台(TOP)的SDK已经非常多年没有更新了.不支持python3.自己动手改了半天,还是不太正常,索性不用它,自己写一个算了 ...

  10. springboot整合docker部署(两种构建Docker镜像方式)--2019-3-5转

    原文:https://www.cnblogs.com/shamo89/p/9201513.html 项目结构 package hello; import org.springframework.boo ...