GithubHelp home page GithubHelp logo

wu-gq / messagequeue Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 5.0 139 KB

通过阻塞队列和延时队列,实现在非延时情况以及延时情况下的生产者消费者模式

License: MIT License

C# 100.00%
blockingqueue delayqueue

messagequeue's Introduction

MessageQueue

通过阻塞队列和延时队列,实现在非延时情况以及延时情况下的生产者消费者模式

UML Class Diagram

UML Class Diagram

关键对象说明

  • DelayDispatcherQueue

    延时队列
    原理:《采用简易的环形延时队列处理秒级定时任务的解决方案》
    当检测到数据到期时,取出数据,并使用委托的方式,将数据交给其它模块进行处理

  • MessageQueue

    非延时阻塞消息队列

  • MessageQueueDelay

    延时阻塞消息队列
    将数据保存至延时队列,待数据到期后,将数据放入阻塞队列中,等待处理
    TODO: 可以不将取出数据再次放入阻塞队列,直接进行处理吗?

  • MillisecondTimer

    计时器对象
    来源:Timer计时不准确的问题及解决方法
    延时队列的精确度与计时器对象相关

  • SimpleSynQueue

    阻塞队列
    主要是靠两个信号量AutoResetEvent对象,实现当队列中无数据时,停住取数据线程,直到有数据被放入再继续运行。

  • SynQueue

    阻塞队列
    这是SimpleSynQueue的完整版。虽然在本项目中没有用到这个对象,但是它实现了更多的功能。

messagequeue's People

Contributors

wu-gq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.