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);   











  • 相关阅读:
    工厂模式如何返回Spring的Bean
    Java 中数字和字符串拼接的问题
    vim常用快捷键整理
    单元测试报错NoSuchBeanDefinitionException
    Logback日志基础配置以及自定义配置
    最简单的JAVA解析XML字符串方法
    SpringMvc如何获取请求头请求体的消息
    Java定义三个点Object...
    mybatis-generator自动生成代码插件
    Spring框架的@Valid注解
  • 原文地址:https://www.cnblogs.com/xiaoxxy/p/3592838.html
Copyright © 2011-2022 走看看