Git Product home page Git Product logo

Comments (4)

crossoverJie avatar crossoverJie commented on May 18, 2024

@sosojustdo

嗯,其实我想表达的意思是:

Disruptor 环形队列里的数据只有等到下一轮数据覆盖掉才会被回收。

阻塞的情况肯定是数据没有被消费导致生产者阻塞了,这是一个阻塞队列的基本功能。

from jcsprout.

sosojustdo avatar sosojustdo commented on May 18, 2024

@crossoverJie
阻塞队列要是满了,入队列不是会阻塞吗?“Disruptor 环形队列里的数据只有等到下一轮数据覆盖掉才会被回收。”这句话“下一轮数据覆盖掉” 意思是队列满了还能入队列,典型的场景:生产速度大于消费速度的时候会出现上面情况?,岂不是违背了阻塞队列初衷。disruptor队列刚使用,不太熟悉,望您指教,谢谢。。

from jcsprout.

crossoverJie avatar crossoverJie commented on May 18, 2024

@sosojustdo

"下一轮数据覆盖掉"

忘了说这个前提了,前提是有消费之后才会覆盖。

比如我文章里面模拟的 8 个坑的队列。

主线程写入 10 条数据,消费线程去消费,肯定边消费边生产的。

如下图所示:

典型的场景:生产速度大于消费速度的时候会出现上面情况?

这样的场景肯定会导致生产者阻塞。

我在这里模拟消费比较慢的场景。

public void onEvent(LongEvent event, long sequence, boolean endOfBatch) throws InterruptedException {
LOGGER.info("消费 Event=[{}]",event.getValue()) ;
Thread.sleep(1000);

通过日志会发现生产者很快把 8 个消息写进入,到第 9 个的时候就阻塞了等到消费一条数据之后才会继续生产数据。

dump 线程也会发现 main 线程作为生产者确实是 waiting 状态。

from jcsprout.

sosojustdo avatar sosojustdo commented on May 18, 2024

@crossoverJie
明白了,多谢你的指点

from jcsprout.

Related Issues (20)

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.