[Chromium文档转载,第004章]Mojo Synchronous Calls
Synchronous Calls
Think carefully before you decide to use sync callsAlthough sync calls are convenient, you should avoid them whenever they are not absolutely necessary:
MojomA new attribute [Sync] (or [Sync=true]) is introduced for methods. For example:
interface Foo { [Sync] SomeSyncCall() => (Bar result);};It indicates that when SomeSyncCall() is called, the control flow of the calling thread is blocked until the response is received.
It is not allowed to use this attribute with functions that don’t have responses. If you just need to wait until the service side finishes processing the call, you can use an empty response parameter list:
[Sync]SomeSyncCallWithNoResult() => ();Generated bindings (C++)The generated C++ interface of the Foo interface above is:
class Foo { public: // The service side implements this signature. The client side can also use this signature if it wants to call the method asynchronously. virtual void SomeSyncCall(SomeSyncCallCallback callback) = 0; virtual bool SomeSyncCall(BarPtr* result);};As you can see, the client side and the service side use different signatures. At the client side, response is mapped to output parameters and the boolean return value indicates whether the operation is successful. (Returning false usually means a connection error has occurred.)
At the service side, a signature with callback is used. The reason is that in some cases the implementation may need to do some asynchronous work which the sync method’s result depends on.
Note: you can also use the signature with callback at the client side to call the method asynchronously.
Re-entrancyWhat happens on the calling thread while waiting for the response of a sync method call? It continues to process incoming sync request messages (i.e., sync method calls); block other messages, including async messages and sync response messages that don’t match the ongoing sync call.Please note that sync response messages that don’t match the ongoing sync call cannot re-enter. That is because they correspond to sync calls down in the call stack. Therefore, they need to be queued and processed while the stack unwinds.
Avoid deadlocksPlease note that the re-entrancy behavior doesn’t prevent deadlocks involving async calls. You need to avoid call sequences such as:
Read more |
[Chromium文档转载,第004章]Mojo Synchronous Calls的更多相关文章
- [Chromium文档转载,第003章]Proposal: Mojo Synchronous Methods
Proposal: Mojo Synchronous Methods yzshen@chromium.org 02/02/2016 Overview Currently there are quite ...
- [Chromium文档转载,第002章]Mojo C++ Bindings API
Mojo C++ Bindings API This document is a subset of the Mojo documentation. Contents Overview Getting ...
- [Chromium文档转载,第006章]Chrome IPC To Mojo IPC Cheat Sheet
For Developers > Design Documents > Mojo > Chrome IPC To Mojo IPC Cheat Sheet 目录 1 O ...
- [Chromium文档转载,第001章] Mojo Migration Guide
For Developers > Design Documents > Mojo > Mojo Migration Guide 目录 1 Summary 2 H ...
- [Chromium文档转载,第005章]Calling Mojo from Blink
For Developers > Design Documents > Mojo > Calling Mojo from Blink Variants Let's as ...
- [Chromium文档转载,第007章]JNI on Chromium for Android
Overview JNI (Java Native Interface) is the mechanism that enables Java code to call native function ...
- 用R创建Word和PowerPoint文档--转载
https://www.jianshu.com/p/7df62865c3ed Rapp --简书 Microsoft的Office软件在办公软件领域占有绝对的主导地位,几乎每个职场人士都必须掌握Wor ...
- java实现支付宝接口--文档..转载
//实现java支付宝很简单,只要从支付宝官方下载 http://help.alipay.com/support/index_sh.htm下载程序,配置一下参数就OK了: 1.先到http:/ ...
- iOS开发主要参考文档(转载)
Objective-C,语言的系统详细资料.这是做iOS开发的前题与基础.https://developer.apple.com/library/ios/#documentation/Cocoa/Co ...
随机推荐
- LoadRunner使用入门 进行Webservice负载測试
1.什么是LoadRunner LoadRunner是HP公司的一款付费工具,该工具是一种预測系统行为和性能的负载測试工具. 通过模拟上千万用户实施并发负载来确认和查找问题. 2.什么是负载測试 通过 ...
- POJ 2570 Fiber Network(最短路 二进制处理)
题目翻译 一些公司决定搭建一个更快的网络.称为"光纤网". 他们已经在全世界建立了很多网站.这 些网站的作用类似于路由器.不幸的是,这些公司在关于网站之间的接线问题上存在争论,这样 ...
- Java - 多线程Callable、Executors、Future
http://blog.csdn.net/pipisorry/article/details/44341579 Introduction Callable接口代表一段能够调用并返回结果的代码; Fut ...
- angularjs $location 服务
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...
- iOS开发-sqlite3使用
SQLite3使用 SQLite简介 SQLite,是一款轻型的数据库,是遵守ACID的关系型数据库管理系统,它包含在一个相对小的C库中. SQLite3 在XCode工程中,打开targets,在B ...
- DSU
DSU stands for ‘decorate, sort, undecorate’ and refers to a pattern that is often useful for sorting ...
- python-搭建django环境
python-搭建django环境 标签(空格分隔): python Django简介 Django,发音为[`dʒæŋɡəʊ],是用python语言写的开源web开发框架,并遵循MVC设计.劳伦斯出 ...
- Android--ViewPager-Fragment
package com.cnn.viewpager02; import java.util.ArrayList; import java.util.List; import android.os.Bu ...
- 【DNN控件】
<dnn:DNNDataGrid ID="show" runat="server" DataSourceID="ObjectDataSource ...
- CUDA笔记(十)
下午仔细研究了两个程序,然后搜了一下解决方法 http://blog.sina.com.cn/s/blog_6de28fbd01011cru.html http://blog.csdn.net/che ...