Mojo Core Embedder API
This document is a subset of the Mojo documentation.
Overview
The Mojo Core Embedder API enables process to initialize and use Mojo for IPC, using an implementation of Mojo Core that is statically linked into the application. See the note about dynamic linking here for more information about an alternative approach to Mojo Core initialization.
NOTE: Unless you are introducing a new binary entry point into the system (e.g., a new executable with a new main()
definition), you probably don't need to know anything about the Embedder API. Most processes defined in the Chrome repo today already fully initialize Mojo Core so that all other public Mojo APIs just work out of the box.
Basic Initialization
As an embedder, initializing Mojo Core requires a single call to mojo::core::Init
:
#include "mojo/core/embedder/embedder.h" int main(int argc, char** argv) {
mojo::core::Init(); // Now you can create message pipes, write messages, etc return 0;
}
This enables local API calls to work, so message pipes etc can be created and used. In some cases (particuarly many unit testing scenarios) this is sufficient, but to support any actual multiprocess communication (e.g. sending or accepting Mojo invitations), a second IPC initialization step is required.
IPC Initialization
Internal Mojo IPC implementation requires a background TaskRunner
on which it can watch for inbound I/O from other processes. This is configured using a ScopedIPCSupport
object, which keeps IPC support alive through the extent of its lifetime.
Typically an application will create a dedicated background thread and give its TaskRunner
to Mojo. Note that in Chromium, we use the existing “IO thread” in the browser process and content child processes. In general, any thread used for Mojo IPC support must be running a base::MessageLoop::TYPE_IO
loop.
#include "base/threading/thread.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/embedder/scoped_ipc_support.h" int main(int argc, char** argv) {
mojo::core::Init(); base::Thread ipc_thread("ipc!");
ipc_thread.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); // As long as this object is alive, all Mojo API surface relevant to IPC
// connections is usable, and message pipes which span a process boundary will
// continue to function.
mojo::core::ScopedIPCSupport ipc_support(
ipc_thread.task_runner(),
mojo::core::ScopedIPCSupport::ShutdownPolicy::CLEAN); return 0;
}
This process is now fully prepared to use Mojo IPC!
Note that all existing process types in Chromium already perform this setup very early during startup.
Connecting Two Processes
Once IPC is initialized, you can bootstrap connections to other processes by using the public Invitations API.
Mojo Core Embedder API的更多相关文章
- Mojo C++ System API
This document is a subset of the Mojo documentation. Contents Overview Scoped, Typed Handles Message ...
- 使用 Swagger 自动生成 ASP.NET Core Web API 的文档、在线帮助测试文档(ASP.NET Core Web API 自动生成文档)
对于开发人员来说,构建一个消费应用程序时去了解各种各样的 API 是一个巨大的挑战.在你的 Web API 项目中使用 Swagger 的 .NET Core 封装 Swashbuckle 可以帮助你 ...
- 在ASP.NET Core Web API上使用Swagger提供API文档
我在开发自己的博客系统(http://daxnet.me)时,给自己的RESTful服务增加了基于Swagger的API文档功能.当设置IISExpress的默认启动路由到Swagger的API文档页 ...
- Docker容器环境下ASP.NET Core Web API应用程序的调试
本文主要介绍通过Visual Studio 2015 Tools for Docker – Preview插件,在Docker容器环境下,对ASP.NET Core Web API应用程序进行调试.在 ...
- 在docker中运行ASP.NET Core Web API应用程序
本文是一篇指导快速演练的文章,将介绍在docker中运行一个ASP.NET Core Web API应用程序的基本步骤,在介绍的过程中,也会对docker的使用进行一些简单的描述.对于.NET Cor ...
- ASP.NET Core Web API Cassandra CRUD 操作
在本文中,我们将创建一个简单的 Web API 来实现对一个 “todo” 列表的 CRUD 操作,使用 Apache Cassandra 来存储数据,在这里不会创建 UI ,Web API 的测试将 ...
- 在Mac下创建ASP.NET Core Web API
在Mac下创建ASP.NET Core Web API 这系列文章是参考了.NET Core文档和源码,可能有人要问,直接看官方的英文文档不就可以了吗,为什么还要写这些文章呢? 原因如下: 官方文档涉 ...
- ASP.NET Core Web API 开发-RESTful API实现
ASP.NET Core Web API 开发-RESTful API实现 REST 介绍: 符合REST设计风格的Web API称为RESTful API. 具象状态传输(英文:Representa ...
- Core Web API上使用Swagger提供API文档
在ASP.NET Core Web API上使用Swagger提供API文档 我在开发自己的博客系统(http://daxnet.me)时,给自己的RESTful服务增加了基于Swagger的AP ...
随机推荐
- Android 制作类似支付圆圈和打钩界面ProgressWheel
首先要说明的是,制作圆圈旋转的效果并不是博主做的,是参照了github上的一个代码,只是在上面添加了修改,对其优化并增加了一个打钩的动画. 先来看下效果,1+的手机获取root权限真是难,没法录屏,只 ...
- Spring Batch 高级-
spring batch / 并行处理 / 多线程 分区 1. 并行处理,多线程,分区 http://blog.csdn.net/github_36849773/article/details/692 ...
- 11、E-commerce in Your Inbox:Product Recommendations at Scale-----产品推荐(prod2vec和user2vec)
一.摘要 本文提出一种方法,将神经语言模型应用在用户购买时间序列上,将产品嵌入到低维向量空间中.结果,具有相似上下文(即,其周围购买)的产品被映射到嵌入空间中附近的向量. 二.模型: 低维项目向量表示 ...
- HTML特殊符号对照表、常用的字符实体
来源:http://tool.xker.com/htmlchar.php 最常用的字符实体 显示结果 描述 实体名称 实体编号 空格 < 小于号 < < > 大于号 ...
- BZOJ 2260 商店购物(最小树形图)
不会最小树形图的出门左转 其实如果确定每种商品第一件的购买顺序,那么剩下的商品肯定是以最优惠价格购买的. 如何确定各种商品第一件购买时的最小价值呢? 考虑如果购买了\(a_i\)这种商品,那么就能以\ ...
- [转]Python常用字符串
转自:http://blog.csdn.net/daemonpei/article/details/6325762 字符串相关操作: + :string1+string2 #联接字符串,将后一个串链接 ...
- MyBatis学习总结(19)——Mybatis传多个参数(三种解决方案)
据我目前接触到的传多个参数的方案有三种. 第一种方案 DAO层的函数方法 Public User selectUser(String name,String area); 对应的Mapper.xm ...
- HDU 1709
MB,一开始就想到是不是只要加上一个不选择砝码的情况,但一直没动手做,因为看了看网上了,觉得总有点复杂,认为自己想错了.... 相信自己 #include <iostream> #incl ...
- Android多媒体学习六:利用Service实现背景音乐的播放
Android同意我们使用Service组件来完毕后台任务.这些任务的同意不会影响到用户其它的交互. 1.Activity类 [java] view plaincopy package demo.ca ...
- 2015级C++第2周实践项目
[项目1 - 宣告"主权"] 你已经是CSDN博客主了,用IT人特有的方式,编一段程序.在屏幕上输出你想说的话.按要求公布博文,作为我们的开山之作. [项目2 - 胖子不想说体重] ...