ProceduralDataflow | library uses the custom awaiter feature | Functional Programming library
kandi X-RAY | ProceduralDataflow Summary
kandi X-RAY | ProceduralDataflow Summary
This library uses the custom awaiter feature in C# 5 and the task-like feature in C# 7 to enable C# developers to write dataflows in a procedural way. The dataflow pattern is like the producer-consumer pattern. However, in the dataflow pattern, the flow is not linear. It can contain branches and loops.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ProceduralDataflow
ProceduralDataflow Key Features
ProceduralDataflow Examples and Code Snippets
Community Discussions
Trending Discussions on ProceduralDataflow
QUESTION
I have two BlockingCollection
objects, collection1
and collection2
. I want to consume items from these collections giving priority to items in collection1
. That is, if both collections have items, I want to take items from collection1
first. If none of them have items, I want to wait for an item to be available.
I have the following code:
...ANSWER
Answered 2017-Sep-02 at 12:27First, short answers to your concrete questions.
Does it throw if
CompleteAdding
was called on any collection? or both collections?
Both (all) - but only if there are no available elements in any collection.
What if
CompleteAdding
was called and the collection still has some items, does it throw?
No. If there is available element in the collection, it will be removed from the collection and returned to the caller.
Conclusion
Apparently the documentation is unclear. The part
or
CompleteAdding()
has been called on the collection
should have been formulated differently - something like
or there is no available element in any of the collections and
CompleteAdding()
has been called on all the collections
Rationale
Well, I know relying on the implementation is not a good practice, but when the documentation is unclear, the implementation is the only reliable and official source I can think of. So taking the reference source, both TakeFromAny
and TryTakeFromAny
call a private method TryTakeFromAnyCore
. It starts with the following:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ProceduralDataflow
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page