Is the TPL Dataflow SingleProducerConstrained
option referring to the number of source blocks or the minimum total parallelism degree of the source blocks?
i.e. if I only have one source block linking to a block with this option, must the MaxDegreeOfParallelism
of the source be 1 or not?
No, it means that (from MSDN):
methods like
Post
,Complete
,Fault
, andOfferMessage
will never be called concurrently.
So you should set this property to true
(false
is the default value) if you're 100%-sure that the block will get messages in it from only one source at a given moment. Examples:
lock
around all the method sending something to the blockNow back to your question:
if I only have one source block linking to a block with this option, must the
MaxDegreeOfParallelism
of the source be 1 or not?
It should be 1
, as if it will be more than that, it can ruin some checks which are dropped with SingleProducerConstrained
set to true
.