Git Product home page Git Product logo

Comments (3)

FranzBusch avatar FranzBusch commented on June 30, 2024 2

@twittemb Is right here that this is something we ought to be able to do one variadic generics land. My position right now is to avoid adding sequence based APIs since they have a few downsides such as introducing an array allocation which could be avoided.

What I can recommend you for the time being is either of these two:

  1. If merge is last transformation applied to your sequence chain then you can as @twittemb pointed out maybe use a task group and merge from there by just creating a child task for each upstream and calling next on the group repeatedly.
  2. You could copy the code that is used for the implementation of merge and just extend it to whatever arity you need. This involves very minor changes and a bit of code duplication.

from swift-async-algorithms.

twittemb avatar twittemb commented on June 30, 2024 1

Hi

from what I know this is something that should arrive when generic variadics are available so we are not constrained to merging the same types of AsyncSequence.

Perhaps there are workarounds in your case. One that comes to my mind is (perhaps not the most efficient though):

Having a task group where you iterate over every channel you have (a task per channel) and send the elements to a single Channel. This “output” channel will act as a merging bus. You can then iterate over this single channel in another task.

from swift-async-algorithms.

tonyarnold avatar tonyarnold commented on June 30, 2024

Thanks to you both - that guidance and info is much appreciated.

I'll see if I can work out how to extend the existing code to support different arities in my local project.

I'll also go read up on the parameter packs pitch by Holly and Slava - I'm really excited by this bit of work!

from swift-async-algorithms.

Related Issues (20)

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.