Coder Social home page Coder Social logo

glib-senders's People

Contributors

maikel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

glib-senders's Issues

Implement for_each as a complement to when_any

template <class... Senders>
auto for_each(Sender... senders) -> std::array<for-each-sender, sizeof...(Senders)>

This algorithm takes N senders and returns an array of N senders. Let std::array result = for_each(senders...) denote the returned array. The first element of result forwards the first completion, the second element forwards the second completion and so on.

If any sender of result is connected to a receiver, all input senders will be connected to intermediate receivers. If any operation is started, all intermediate operations will be started.

When all connected senders of result have completed, the outstanding operations are stopped.

Example:

  • for_each gets 3 input senders and return and 3 output senders
  • only 2 of 3 output senders are connected to a receiver
  • when two operations complete the third operation will be stopped

Implement when_any

I can not find any when_any algorithm in stdexec. A poor mans when_any could be something like this

template <typename... Senders> auto when_any(Senders&&... senders) {
  auto and_just_stopped = stdexec::let_value([](auto&&...) { return stdexec::just_stopped(); });
  return stdexec::when_all(
             (std::forward<Senders>(senders) | and_just_stopped)...) //
         | stdexec::upon_stopped([] {});;
}

But the resulting sender is not stoppable and it does not propagate any values.

I see at least two different behaviours:

  1. Returns one sender. If any input senders completes with a value, then stop the other senders and propagate this one value to the next receiver.

  2. Returns a range of senders

  3. Returns a ManySender as in unifex

  4. Returns an AsyncStream as in unifex

I like (4) most. But since (2-4) are out of scope I want to implement (1)

  • when_any returns a sender and stops all other input senders upon completion
  • when_any forwards any value, error or stop signal of the first operation that completes
  • when_any is stoppable

manual_life_time wrapper for Receiver in schedule_operation

The ::GSource*, which is the task interface of glib, is deallocated by glib. The destructor is currently called manually in the finalize callback in its vtable ::GSourceFunc.

Consider to implement a manual_life_time<T> wrapper to manage the life time of the Receiver object in schedule_operation.

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.