Giter Club home page Giter Club logo

easyio's Introduction

简介

这是一个基于 Linux 平台的 IO 框架,适合入门学习。

框架被拆分为通信层、协议层与业务层,各层都应用面向对象设计实现了高内聚、低耦合,通过多层派生充分复用共性代码,最大程度减少冗余。通信层又横向拆分为通道类和监视器类,通道类负责数据传输,通过派生与组合可灵活支持多种通信方式(串口,蓝牙,TCP,SSL),监视器类管理和调度通道,其中应用了 select/epoll 等 IO 多路复用技术,保证了单线程 IO 效率。协议层采用状态机实现数据解析,这其实是在手动模拟协程,解析过程可随时暂停和重入,以充分发挥非阻塞 IO 的效率。此外,协议类和通道类之间的耦合,并未简单使用组合关系,而是基于函数式编程**(函数是一等公民、闭包提供更小粒度的变量绑定),将二者关联起来,使得“不需要协议的通道”这一语义能够自然表达,避免了冗余代码。

在 usage 目录,是基于这个框架编写的几个应用 demo,如聊天程序、协议通信、多线程 HTTP 文件下载等。整个项目都使用 gn/ninja 工具组织构建,编译速度较快,便于维护和扩展。

编译构建

环境依赖

  • linux 系统

  • gcc 工具链

  • openssl 开发库

用 gn 生成 ninja 编译描述文件

仓内已经预置了 gn 和 ninja 工具(linux 64位版),直接执行如下命令:

./build/gn gen -C out

用 ninja 编译所需的应用/测试模块

为了演示 EasyIO 框架的用法,在 usage 目录下给出了一些示例应用程序,对应的可执行模块名请查看根目录下的 BUILD.gn 文件,例如编译其中的 HTTP 多线程下载器http_downloader,执行以下命令:

 ./build/ninja -C out http_downloader

如果需要构建 usage 目录下的所有演示程序,则执行:

./build/ninja -C out

构建出的可执行文件都在 out 目录中。

easyio's People

Contributors

likeusummer avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.