Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the [full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
This library is counterpart to [P1055 - *A Modest Executor Proposal*](http://wg21.link/p1055r0).
*pushmi* is a header-only library that uses CMake to build, requires GCC trunk to build and has dependencies on catch2 for testing purposes.
*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
*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.
```cpp
structpromise<void>{
voidset_value();
voidset_exception(std::exception_ptr);
future<void>get_future();
};
```
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).
```cpp
std::promise<void>p;
autof=p.get_future();
p.set_value();
// or
// p.set_exception(std::exception_ptr{});
f.get();
```
it is this convolution that creates the race between the producer and consumer that requires expensive internal state to resolve.
## `none`
The `none` type in the library provides simple ways to construct new implementations of the None concept.
construct a sink type that accepts any error type (and aborts on error)
```cpp
none<>n;
archetype_nonean;// this is a using alias for none<>
```
construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets
```cpp
// provide done
auton0=none{on_done{[](){}}};
// these are quite dangerous as they suppress errors
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing none. The state must be a None, but can be a super-set with additional state for this filter.
construct a type-erased type for a particular 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.
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing single. The state must be a Single, 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.
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing deferred. The state must be a NoneSender, but can be a super-set with additional state for this filter.
construct a type-erased type for a particular 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.
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing single_deferred. 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.
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing time_single_deferred. 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.