proxygen
|
This library is counterpart to P1055 - A Modest Executor Proposal.
pushmi is a header-only library that uses git submodules for dependencies (git clone --recursive
), uses CMake to build, requires compliant C++14 compiler to build and has dependencies on meta and catch2 and some other libraries for testing and examples.
pushmi is an implementation for prototyping how Futures, Executors can be defined with shared Concepts. These Concepts can be implemented over and over again to solve different problems and make different tradeoffs. User implementations of the Concepts are first-class citizens due to the attention to composition. Composition also enables each implementation of the Concepts to focus on one concern and then be composed to build more complex solutions.
Callbacks are very familiar though they take many forms. It is precisely the multiplicity of forms that make Callbacks difficult to compose.
A minimal callback might be passed some state. The state might include an error or might only be a result code. Maybe this is delivered as one parameter, or as many parameters. Maybe the Callback is called once, or many or even zero times.
Promises provide a stable contract for Callbacks of a single result or error.
std::promise<>
The interface for std::promise<void>
is fairly straightforward.
usage is also simple, but a bit convoluted (the promise produces the future, has the result set_ function called, and only then is future::get called to get the result).
it is this convolution that creates the race between the producer and consumer that requires expensive internal state to resolve.
receiver
The receiver
type in the library provides simple ways to construct new implementations of the Receiver concept.
construct a sink type that accepts any value or error type (and aborts on error)
construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing receiver. The state must be a Receiver, but can be a super-set with additional state for this filter.
construct a type-erased type for a particular T & E (each of which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors.
single_sender
The single_sender
type in the library provides simple ways to construct new implementations of the SingleSender concept.
construct a producer of nothing, aka never()
construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing single_sender. The state must be a SingleSender, but can be a super-set with additional state for this filter.
construct a type-erased type for a particular T & E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors.
time_single_sender
The time_single_sender
type in the library provides simple ways to construct new implementations of the TimeSingleSender concept.
construct a producer of nothing, aka never()
construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing time_single_sender. The state must be a SingleSender, but can be a super-set with additional state for this filter.
construct a type-erased type for a particular T & E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors.