zoukankan      html  css  js  c++  java
  • IPC Gateway 设计

    1. IPC Gateway对外提供的功能:

     IPC的register/request/reply/notification服务。

    2. IPC Gatew的实现原理:

    各个具体的服务注册自己的回调函数,注册时提供服务自身的IPC Channel号。IPC Gateway 创建一个Map结构区记录各自的回调函数,当IPC Gateway接收到来字IPC layer的数据/消息,就会触发之前所注册的回调函数去处理数据。

    Callback 函数的类型:

    typedef void (*invoke_callback)(const void *ctx, UInt16 function, UInt8 *rx_data,Int32 len);
    typedef void (*notification_callback)(UInt16 function, UInt8 *rx_data, Int32 len);
    typedef void (*request_callback)(const void *ctx, UInt8 *rx_data, Int32 len);

    3. 核心接口的设计:

    /*Initialize the ipc gateway. Used to initialize the inside map. */

    void ipc_gw_init();  

     /*  Register callback function via channel number.*/

    error_type ipc_gw_register(Int32 channel, notification_callback ntf_cb, request_callback req_cb);  

    /* Send request ipc message.*/

    error_type ipc_gw_send_request(Int32 channel, UInt16 function,const UInt8 *data,Int32 len,const void *context, invoke_callback cb);  

    /*Send request ipc message without reply. */

    error_type ipc_gw_send_request_no_reply(Int32 channel, UInt16 function,const UInt8 *data,Int32 len); 

    /* Reply the request after processing. */

    error_type ipc_gw_send_reply(request_context_t *context, const UInt8 *data,Int32 len);   

     /* Send notification without reply. */

    error_type ipc_gw_send_notification(Int32 channel, UInt16 function,const UInt8 *data,Int32 len);  

     /*Receive IPC message. Dispatch the message to respect registerd callback functions. */

    error_type ipc_gw_receive_msg (Int32 channel, const UInt8* buf, Int32 len);   











  • 相关阅读:
    单位矩阵
    向量的内积(也叫点积)
    svm
    vue.js 中this.$router.push()的使用
    Spring Bean 的加载过程
    Solr是什么?
    Servlet中如何获取用户提交的查询参数或表单数据?
    Redis面试题大全含答案
    Overload和Override的区别。Overloaded的方法是否可以改变返回值的类型?
    抽象类(abstract class)和接口(interface)有什么异同?
  • 原文地址:https://www.cnblogs.com/xiaoxxy/p/3592838.html
Copyright © 2011-2022 走看看