Coder Social home page Coder Social logo

tpldataflowhelpers_prioritybufferblock's People

Contributors

kevdever avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tpldataflowhelpers_prioritybufferblock's Issues

A few issues by reading the source code

I can see a few issues with the implementation of the PriorityBufferBlock<T> class.

  1. The Post method doesn't propagate the bool return value of the underlying invocations. So if the three internal blocks have been configured with BoundedCapacity and the limit has been reached, the offered item will be declined, and the caller of the PriorityBufferBlock<T>.Post will not be notified about it. The same is true for the SendAsync method.

  2. Linking the PriorityBufferBlock<T> to a target block with the PropagateCompletion enabled is broken. The completion will be propagated when the first of the three internal blocks completes, not when all complete. For example after calling PriorityBufferBlock<T>.Complete(), when the _highPriorityBuffer is emptied it will trigger the completion of the target, so any messages that are still inside the _lowPriorityBuffer will be rejected by the target. These messages will not be consumed.

  3. The _messagesByBlock is a dictionary where messages are only added, and never removed. So it can be a memory leak. My understanding is that the method that adds messages to the dictionary, the ReserveMessage, is never going to be called under normal circumstances. That's because the three internal blocks are linked to the target directly, and so the target is totally unaware of the existence of the PriorityBufferBlock<T>. When the internal blocks call the OfferMessage on the target, they are going to pass themselves as the source argument. So the target might call the ReserveMessage on the internal blocks, not on the wrapper class. If my understanding is correct, the aforementioned memory leak will never actually happen in practice, and the _messagesByBlock dictionary is a complexity that could be removed. The ConsumeMessage/ReserveMessage/ReleaseReservation methods could just throw a NotSupportedException.

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.