20 lines
		
	
	
		
			481 B
		
	
	
	
		
			C++
		
	
	
	
	
	
		
		
			
		
	
	
			20 lines
		
	
	
		
			481 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| 
								 | 
							
								#include<iostream>
							 | 
						||
| 
								 | 
							
								#include "co_context/io_context.h"
							 | 
						||
| 
								 | 
							
								#include "co_context/lazy_io.h"
							 | 
						||
| 
								 | 
							
								using namespace std;
							 | 
						||
| 
								 | 
							
								using namespace co_context;
							 | 
						||
| 
								 | 
							
								task<> the_answer(int t) {
							 | 
						||
| 
								 | 
							
								    const char* name = "hello";
							 | 
						||
| 
								 | 
							
								    cout << "lazyout" << endl;
							 | 
						||
| 
								 | 
							
								    co_await lazy::write(1, { name, 5 }, 10);
							 | 
						||
| 
								 | 
							
								    cout << name << t << endl;
							 | 
						||
| 
								 | 
							
								    co_return;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								int main() {
							 | 
						||
| 
								 | 
							
								    io_context context;
							 | 
						||
| 
								 | 
							
								    int a = 3;
							 | 
						||
| 
								 | 
							
								    context.co_spawn(the_answer(a));
							 | 
						||
| 
								 | 
							
								    context.co_spawn(the_answer(5));
							 | 
						||
| 
								 | 
							
								    context.start();
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 |