Mojo C++ Platform API
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.
A 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));
// ...
}
Mojo C++ Platform API的更多相关文章
- Mojo C++ System API
This document is a subset of the Mojo documentation. Contents Overview Scoped, Typed Handles Message ...
- FatSecret Platform API
在现阶段饮食类的APP发展的非常迅猛,尤其在校园中,学生只需要凭借一个手机就能买到自己想要的食物,真正做到了足不出户.可是如果我们想独立完成一个app就需要有相应的数据支持,这里给大家介绍一个国外的开 ...
- Mojo C++ Bindings API
This document is a subset of the Mojo documentation. Contents Overview Getting Started Interfaces Ba ...
- Mojo Core Embedder API
This document is a subset of the Mojo documentation. Contents Overview Basic Initialization IPC Init ...
- [Chromium文档转载,第002章]Mojo C++ Bindings API
Mojo C++ Bindings API This document is a subset of the Mojo documentation. Contents Overview Getting ...
- WeChat Official Account Admin Platform API Introduction
Keyword: WeChat API Introduction Message and GeneralAuthor: PondBay Studio[WeChat Developer EXPERT] ...
- 来自HeroKu的HTTP API 设计指南(中文版)
原文转自:http://get.jobdeer.com/343.get 来自HeroKu的HTTP API 设计指南(中文版) 翻译 by @Easy 简介 本指南中文翻译者为 @Easy ,他是国内 ...
- HTTP API 设计指南(中文版) restfull
http://www.css88.com/archives/5121 目录 基础 总是使用TLS 在Accepts头中带上版本号 通过Etags支持缓存 用Request-Ids追踪请求 用Range ...
- Http API设计
Heroku团队根据heroku platform api和他们自己内部系统的实践经验总结了一些http api设计的准则,发布到了github上. 地址:https://github.com/int ...
随机推荐
- $(window).load(function(){})跟$(document).ready(function(){})跟$(function(){})区别
1.页面DOM加载完成 2.$(document).ready(function(){}) 的简写是 $(function(){}) 执行 3.图片样式等所有HTML元素加载完毕 4.$(windo ...
- poj_3468线段树成段更新求区间和
#include<iostream> #include<string.h> #include<cstdio> long long num[100010]; usin ...
- ES线程池设置
每个Elasticsearch节点内部都维护着多个线程池,如index.search.get.bulk等,用户可以修改线程池的类型和大小,线程池默认大小跟CPU逻辑一致 一.查看当前线程组状态 cur ...
- caffe中lenet_train_test.prototxt配置文件注解
caffe框架下的lenet.prototxt定义了一个广义上的LeNet模型,对MNIST数据库进行训练实际使用的是lenet_train_test.prototxt模型. lenet_train_ ...
- C#--DataGridView添加DateTimePicker时间控件
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 新疆大学(新大)OJ xju 1009: 一带一路 prim求最短路径+O(n)素数筛选
1009: 一带一路 时间限制: 1 Sec 内存限制: 128 MB 题目描述 一带一路是去去年习大大提出来的建设“新丝绸之路经济带”和“21世纪海上丝绸之路”的战略构想.其中就包括我们新疆乌鲁木 ...
- Swift 闭包中 self? 的由来
class UIViewSpringAnimator: SwipeAnimator { // 动画完成的闭包 var completion:((Bool) ->Void)? func addCo ...
- C#网络编程—HTTP应用编程(转)
https://www.cnblogs.com/huangxincheng/archive/2012/01/09/2316745.html https://www.cnblogs.com/wangqi ...
- java上传文件工具类
这个是之前整理之前所学时与使用java向邮箱发送邮件一块找到的,一起贴出来供大家参考: import java.awt.image.BufferedImage; import java.io.File ...
- win10安装node/yarn报错2503/2502
当我们从node官网下载windows安装包时会得到一个msi文件,由于win10的安全策略比较严格,所以我们在右键菜单上找不到以管理员运行这个按钮: 普通的exe文件: msi文件: 解决办法: 此 ...