maikel / glib-senders Goto Github PK
View Code? Open in Web Editor NEWSenders and Receivers for the GNOME Glib library
License: The Unlicense
Senders and Receivers for the GNOME Glib library
License: The Unlicense
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:
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:
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.
Returns a range of senders
Returns a ManySender as in unifex
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 completionwhen_any
forwards any value, error or stop signal of the first operation that completeswhen_any
is stoppableThe ::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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.