kevdever / tpldataflowhelpers_prioritybufferblock Goto Github PK
View Code? Open in Web Editor NEWA TPL Dataflow-compatible ISourceBlock supporting priority queueing
A TPL Dataflow-compatible ISourceBlock supporting priority queueing
I can see a few issues with the implementation of the PriorityBufferBlock<T>
class.
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.
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.
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.