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. iOS开发-Tools-CocoaPods

    CocoaPods是什么? 当你开发iOS应用时,会经常使用到很多第三方开源类库,比如JSONKit,AFNetWorking等等.可能某个类库又用到其他类库,所以要使用它,必须得另外下载其他类库,而 ...

  2. 关于PageRank的总结

    好久不用CSDN,最近想给带的本科生实验课开个期末习题专题页,发现CSDN的博客忽然要绑定之类.只好弃用回博客园写学习总结了.塞翁失马焉知非福. *************************** ...

  3. avalon 双工绑定以及一个按钮多个事件

    <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    ...

  4. JavaScript学习——完善注册页面表单校验

    1.之前我们已经使用弹出框的方式实现了表单校验的功能,但是此种方式用户体验效果很差 我们希望做成把提示信息和校验结果放在输入栏的后面. 2.步骤分析 (此案例基于HTML&CSS——网站注册页 ...

  5. windows共享如何重新登录,或用另外的用户登录

    使用net use * /del 可以结束已有的所有连接,或net use \\192.168.1.10  /del可以结束指定连接.比如想重新登录共享的话,就用这个命令结束原来的连接,就可以重新登录 ...

  6. 关于exsi的虚拟网络

    相关术语: VM Network 默认的网络 VSwitch   (默认)标准交换机 (exsi的内核中) Port groups  (用来定义各个不同vlan) DVSwitch分布式交换机(exs ...

  7. ES6 学习3 函数

    1.函数默认参数 在ES5我们给函数定义参数默认值是怎么样? function action(num) { num = num || 200 //当传入num时,num为传入的值 //当没传入参数时, ...

  8. php xml 的基本操作类

    class xmlMessage{ protected $doc; protected $rootKey; public function __construct() { $this->doc ...

  9. CF1005F Berland and the Shortest Paths (树上构造最短路树)

    题目大意:给你一个边权为$1$的无向图,构造出所有$1$为根的最短路树并输出 性质:单源最短路树上每个点到根的路径 ,一定是这个点到根的最短路之一 边权为$1$,$bfs$出单源最短路,然后构建最短路 ...

  10. React 使用link在url添加参数(url中不可见)

    1. 在要跳转页面添加<Link to={{ pathname: `/staffManagement/cardRecord`, state: {time: YYYY-MM-dd, name: s ...