Mais conteúdo relacionado
Semelhante a 腾讯大讲堂58 拍拍app platform中间件解决方案简介 (20)
腾讯大讲堂58 拍拍app platform中间件解决方案简介
- 1. 腾 讯 大 讲 堂 第五十八期 研发管理部 大讲堂主页: http://km.oa.com/class 与讲师互动: http://km.oa.com/group/class
- 14. 传统 Statful 状态机的实现 Int OnExecute() { switch(m_cStat) { case S_START: OnWebRequest(WebRequest[out]); // Do Something… DoDB1Request(DB1Request[in]); m_cStat = S_CHECK_1; return 1 ; case S_CHECK_1: OnDB1Response(DB1Response[out]); // Do Something… DoDB2Request(DB2Request[in]); m_cStat = S_CHECK_2; return 1 ; case S_CHECK_2: OnDB2Response(DB2Response[out]); // Do something… DoWebResponse(WebResponse[in]); m_cStat = S_FINISH; return 0 ; } // … return 0; }
- 15. 优化后的 Statful 状态机的实现 Int OnExecute() { OnWebRequest(WebRequest[out]); // Do Something… CallDB1(DB1Request[in], DB1Response[out]); // Do Something… with DB1Response CallDB2(DB2Request[in], DB2Response[out]); // Do Something… with DB2Response DoWebResponse(WebResponse[in]); // … return 0; } 奥妙就在此: CallDB1(DB1Request[in], DB1Response[out]) { DoDB1Request(DB1Request[in]); Schedule();// Linux System Call swapcontext(…) OnDB1Response(DB1Response[out]); }
Notas do Editor
- 将底层重复代码封装成一个容器服务器 (Container) ,并提供统一的接口和日志格式,物理上把应用层代码封装成动态链接库,有效地隔离了底层代码改动带来的影响。 Netio 提供了独立的网络接入方案,部署在 AppContainer 的前端和后端,异步处理 TCP 或 UDP 数据,并将其传入 AppContainer 的前置 / 后置消息队列中,待 AppContainer 逐一处理。降低了 AppContainer 的复杂度和繁忙度。