Skip to content

Commit

Permalink
fix readme, and missing header
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Chabot committed Jul 9, 2019
1 parent efd0809 commit a51c5cd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,41 @@ void foo() {
}
```
### Future Streams
#### Producing Future streams
```cpp
aom::Stream_future<int> get_stream() {
aom::Stream_promise<int> prom;
auto result = prom.get_future();
std::thread worker([p = std::move(prom)]() mutable {
p.push(1);
p.push(2);
p.push(3);
p.push(4);
// If p is destroyed, the stream is implicitely failed.
p.complete();
});
worker.detach();
return result;
}
```

#### Consuming Future streams
```cpp
auto all_done = get_stream().for_each([](int v) {
std::cout << v << "\n";
}).then([](){
std::cout << "all done!\n";
});

all_done.get();
```
## Performance notes
The library assumes that, more often than not, a callback is attached to the
Expand Down
1 change: 1 addition & 0 deletions include/var_future/future.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "var_future/impl/storage_decl.h"

#include <memory>
#include <string>

namespace aom {

Expand Down

0 comments on commit a51c5cd

Please sign in to comment.