Mojo C++ Platform API

This document is a subset of the Mojo documentation.

Overview

The Mojo C++ Platform API provides a lightweight set of abstractions around stable platform primitive APIs like UNIX domain sockets and Windows named pipes. This API is primarily useful in conjunction with Mojo Invitations to bootstrap Mojo IPC between two processes.

Platform Handles

The PlatformHandle type provides a move-only wrapper around an owned, platform-specific primitive handle types. The type of primitive it holds can be any of the following:

  • Windows HANDLE (Windows only)
  • Fuchsia zx_handle_t (Fuchsia only)
  • Mach send right (OSX only)
  • POSIX file descriptor (POSIX systems only)

See the header for more details.

Platform Channels

The PlatformChannel type abstracts a platform-specific IPC FIFO primitive primarily for use with the Mojo Invitations API. Constructing a PlatformChannel instance creates the underlying system primitive with two transferrable PlatformHandle instances, each thinly wrapped as a PlatformChannelEndpoint for additional type-safety. One endpoint is designated as local and the other remote, the intention being that the remote endpoint will be transferred to another process in the system.

See the header for more details. See the Invitations documentation for an example of using PlatformChannel with an invitation to bootstrap IPC between a process and one of its newly launched child processes.

Named Platform Channels

For cases where it is not feasible to transfer a PlatformHandle from one running process to another, the Platform API also provides NamedPlatformChannel, which abstracts a named system resource that can facilitate communication similarly to PlatformChannel.

NamedPlatformChannel upon construction will begin listening on a platform-specific primitive (a named pipe server on Windows, a domain socket server on POSIX, etc.). The globally reachable name of the server (e.g. the socket path) can be specified at construction time via NamedPlatformChannel::Options::server_name, but if no name is given, a suitably random one is generated and used.

// In one process
mojo::NamedPlatformChannel::Options options;
mojo::NamedPlatformChannel named_channel(options);
OutgoingInvitation::Send(std::move(invitation),
named_channel.TakeServerEndpoint());
SendServerNameToRemoteProcessSomehow(named_channel.GetServerName()); // In the other process
void OnGotServerName(const mojo::NamedPlatformChannel::ServerName& name) {
// Connect to the server.
mojo::PlatformChannelEndpoint endpoint =
mojo::NamedPlatformChannel::ConnectToServer(name); // Proceed normally with invitation acceptance.
auto invitation = mojo::IncomingInvitation::Accept(std::move(endpoint));
// ...
}
Powered by GitilesPrivacy

Mojo C++ Platform API的更多相关文章

  1. Mojo C++ System API

    This document is a subset of the Mojo documentation. Contents Overview Scoped, Typed Handles Message ...

  2. FatSecret Platform API

    在现阶段饮食类的APP发展的非常迅猛,尤其在校园中,学生只需要凭借一个手机就能买到自己想要的食物,真正做到了足不出户.可是如果我们想独立完成一个app就需要有相应的数据支持,这里给大家介绍一个国外的开 ...

  3. Mojo C++ Bindings API

    This document is a subset of the Mojo documentation. Contents Overview Getting Started Interfaces Ba ...

  4. Mojo Core Embedder API

    This document is a subset of the Mojo documentation. Contents Overview Basic Initialization IPC Init ...

  5. [Chromium文档转载,第002章]Mojo C++ Bindings API

    Mojo C++ Bindings API This document is a subset of the Mojo documentation. Contents Overview Getting ...

  6. WeChat Official Account Admin Platform API Introduction

    Keyword: WeChat API Introduction Message and GeneralAuthor: PondBay Studio[WeChat Developer EXPERT] ...

  7. 来自HeroKu的HTTP API 设计指南(中文版)

    原文转自:http://get.jobdeer.com/343.get 来自HeroKu的HTTP API 设计指南(中文版) 翻译 by @Easy 简介 本指南中文翻译者为 @Easy ,他是国内 ...

  8. HTTP API 设计指南(中文版) restfull

    http://www.css88.com/archives/5121 目录 基础 总是使用TLS 在Accepts头中带上版本号 通过Etags支持缓存 用Request-Ids追踪请求 用Range ...

  9. Http API设计

    Heroku团队根据heroku platform api和他们自己内部系统的实践经验总结了一些http api设计的准则,发布到了github上. 地址:https://github.com/int ...

随机推荐

  1. php+mysql时报错:Unknown column '' in 'field list'解决方案

    答案来源:http://jingyan.baidu.com/article/9f7e7ec05c5ad76f281554ab.html 很多人在用php+MySQL做网站往数据库插入数据时发现如下错误 ...

  2. 安卓 使用Gradle生成正式签名apk文件

    1. 进入app中的build.gradle下面进行配置 2.进入Gradle下面选择clean和assembleRelese,双击 3.生成成功,前往查看 4.加密更安全

  3. m_Orchestrate learning system---三、session使用完整流程是什么

    m_Orchestrate learning system---三.session使用完整流程是什么 一.总结 一句话总结: 1.在登录成功之后设置session和cookie 2.在公共控制器里面使 ...

  4. ORA-01119、ORA-27040

    SQL> alter tablespace DRSYS add datafile '/ora_data/drsys02.dbf' size 1000m;alter tablespace DRSY ...

  5. POJ 2189 枚举

    题意: n头牛,p长度的道路,问至多包括c头牛的道路最长有多长. 思路: 按照题意暴力就好-- 注意边界. // by SiriusRen #include <cstdio> #inclu ...

  6. 常用css框架 Sass/Less

    Bootstrap less/sass Sass (Syntactically Awesome Stylesheets)是一种动态样式语言,Sass语法属于缩排语法,比css比多出好些功能(如变量.嵌 ...

  7. hadoop 编译自己的jar包并运行

    我修从网上找了份java代码 我为了让它在hadoop下跑起来居然花了两个多小时... 首先最好不要在java代码中设置package...使用default package即可... 然后在java ...

  8. Dropout 下(关于《Dropout: A Simple way to prevent neural networks from overfitting》)

    先上菜单: 摘要: Deep neural nets with a large number of parameters are very powerful machine learning syst ...

  9. Dapper基础知识二

    在下刚毕业工作,之前实习有用到Dapper?这几天新项目想用上Dapper,在下比较菜鸟,这块只是个人对Dapper的一种总结. 2,如何使用Dapper?     首先Dapper是支持多种数据库的 ...

  10. 一个简单的MyBatis项目(应用)

    ### 1. MYBATIS简介  MYBATIS是持久层框架,大大的简化了持久层开发.  当使用MYBATIS框架时,开发人员不必再编写繁琐的JDBC代码,只需要定义好每个功能对应的抽象方法与需要执 ...