zoukankan      html  css  js  c++  java
  • 【移动开发】binder阻塞/非阻塞与单向/双向的问题

    The client thread calling transact is blocked by default until onTransact has finished
    executing on the remote thread. Transaction data consists of android.os.Parcel ob‐
    jects, which are optimized to be sent across processes via the Binder . Arguments and
    |return values are transferred as Parcel objects. These can contain literal arguments or
    custom objects that implement android.os.Parcelable —an interface that defines
    marshalling and unmarshalling of data in a more efficient way than a Serializable .
    The onTransact method is executed on a thread from a pool of binder threads, discussed
    in “Binder Threads” on page 30. This pool exists only to handle incoming requests from
    other processes. It has a maximum of 16 threads, 2 so 16 remote calls can be handled
    concurrently in every process. This requires the implementations of the calls to ensure
    thread safety.
    IPC can be bidirectional. The server process can issue a transaction to the client process
    and reverse the flow: the former server process becomes the client and executes a trans‐
    action on another binder implemented in the former client process, whose own binder
    threads handle the processing. Hence, a two-way communication mechanism between
    two processes can be established. As we will see, this mechanism is important to enable
    asynchronous RPC.
    If the server process starts a transaction, calling transact to send
    a request to the client process while executing onTransact , the
    client process will not receive the incoming request on a binder
    thread, but on the thread waiting for the first transaction to finish.
    Binders also support asynchronous transactions, which you can specify by setting IBin
    der.FLAG_ONEWAY . With that flag set, the client thread will call transact and return
    immediately. A binder will continue calling onTransact on the binder thread in the
    server process, but cannot return any data synchronously to the client thread.
  • 相关阅读:
    14个以春天为主题的网页设计
    使用 CSS3 创建下拉菜单
    视觉灵感:30个漂亮的的网站设计
    Null Object设计模式
    js插件库之图像幻灯片和画廊
    C#读取HTML文件内容写入记事本
    最好的图片水印实现思路
    抽奖系统
    对过万条数据的数据库字段内容批量替换程序
    通用 图片/文字 水印函数
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6158016.html
Copyright © 2011-2022 走看看