Skip to content

possibility to take() from several queues #1

Open

Description

@alex-bermishev

could you, please, show a short example of consuming from multiple BlockingCollection instances
similar to BlockingCollection.TakeFromAny Method

thank you

Activity

  1. gm127 commented on Jan 29, 2019

    @gm127
    Contributor

    @alex-bermishev The .net core implementation of TryTakeFromAnyCore provides an example of how to implement the fast path (i.e. non-blocking). The slow path (i.e. blocking) will be a bit more work. My initial thoughts would be to create a BlockingCollectionAggregator class. The constructor would take as input the data source collections you want to take from. Plus it would have its own internal collection. The aggregator would spin up tasks to wait on each data source collection. When data arrives from any it would get enqueued to its internal collection. The internal collection is what would feed BlockingCollectionAggregator's Take method. The Take method would include the fast path mentioned above. Additional housekeeping would be needed to manage the tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions