-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtrivial.cpp
More file actions
37 lines (27 loc) · 697 Bytes
/
Copy pathtrivial.cpp
File metadata and controls
37 lines (27 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <sstream>
#include "CoroutineStream.h"
using namespace std;
//////////////////////////////
// Simplest possible example showing how to use a CoroutineStream
//////////////////////////////
struct ExampleStreamProducer : public StreamProducer
{
virtual void produce(CoroutineStream &str)
{
str.write("The producer is producing this data\n");
str.write("The producer is also producing this data\n");
}
};
int main()
{
ExampleStreamProducer p;
CoroutineStream s(p);
size_t cnt = 0;
while (const StreamChunk *c = s.peekChunk())
{
cout << c->str() << endl;
s.consumeChunk();
}
return 0;
}