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. springMVC接受参数总结

    springMVC接受参数分类及使用对应注解才能正确接受到参数,否则报400或者接受的参数值为null: 1.接受单个参数 @RequestParam 不需要转json串 2.接受一个实体 @Requ ...

  2. 关于JQuery中的事件冒泡

    什么是事件冒泡? 事件冒泡就是当父元素和子元素存在同一事件时在子元素的事件处理程序中会自动调用其父级元素的事件处理程序. demo: <!DOCTYPE html> <html xm ...

  3. uva 11584 - 字符串 dp

    题目链接 一个长度1000的字符串最少划分为几个回文字符串 ---------------------------------------------------------------------- ...

  4. 路飞学城Python-Day18

    [1.编程范式] 1.面向过程编程 2.面向对象编程 [2.面向过程编程] 面向过程:核心就是过程   什么是过程? 过程指的是解决问题的步骤,先做什么,在作什么,面向过程就像是设计一个流水线,是一种 ...

  5. 解决PNG图片在IE6中背景不透明方法_解决IE6中PNG背

    解决PNG图片在IE6中背景不透明方法_解决IE6中PNG背   目录 解决代码 解决png图片在html中 解决png作为网页背景-css 1.解决PNG图片在IE6中背景不透明的CSS与JS代码 ...

  6. Docker搭建MySQL的PXC集群

    原文:Docker搭建MySQL的PXC集群 一.简介 PXC属于一套近乎完美的mysql高可用集群解决方案,相比那些比较传统的基于主从复制模式的集群架构MHA和MM+keepalived,galer ...

  7. 素数计数函数$\pi(x)\sim \Theta(\frac{x}{\log{x}})$的一个初等方法——素数定理的估计

    $\DeclareMathOperator{\lcm}{lcm}$ 本文的方法来源于GTM 190:"Problems in Algebraic Number Theory",给出 ...

  8. 【codeforces 816B】Karen and Coffee

    [题目链接]:http://codeforces.com/contest/816/problem/B [题意] 给你很多个区间[l,r]; 1<=l<=r<=2e5 一个数字如果被k ...

  9. Linux 环境下/etc/profile和/etc/profile.d 的区别

    Linux 环境下/etc/profile和/etc/profile.d 的区别 区别: 1. 两个文件都是设置环境变量文件的,/etc/profile是永久性的环境变量,是全局变量,/etc/pro ...

  10. flume 读取kafka 数据

    本文介绍flume读取kafka数据的方法 代码: /************************************************************************* ...