Avoid coroutine lambda captures in tcp_channel
This commit is contained in:
		
					parent
					
						
							
								31ca903999
							
						
					
				
			
			
				commit
				
					
						483062f22b
					
				
			
		
					 2 changed files with 19 additions and 12 deletions
				
			
		| 
						 | 
					@ -25,7 +25,7 @@ nano::transport::tcp_channel::tcp_channel (nano::node & node_a, std::shared_ptr<
 | 
				
			||||||
nano::transport::tcp_channel::~tcp_channel ()
 | 
					nano::transport::tcp_channel::~tcp_channel ()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	close ();
 | 
						close ();
 | 
				
			||||||
	debug_assert (!sending_task.joinable ());
 | 
						release_assert (!sending_task.joinable ());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nano::transport::tcp_channel::close ()
 | 
					void nano::transport::tcp_channel::close ()
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,14 @@ void nano::transport::tcp_channel::close ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nano::transport::tcp_channel::start ()
 | 
					void nano::transport::tcp_channel::start ()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	sending_task = nano::async::task (strand, [this] (nano::async::condition & condition) -> asio::awaitable<void> {
 | 
						sending_task = nano::async::task (strand, [this] (nano::async::condition & condition) {
 | 
				
			||||||
 | 
							return start_sending (condition); // This is not a coroutine, but a corotuine factory
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					asio::awaitable<void> nano::transport::tcp_channel::start_sending (nano::async::condition & condition)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						debug_assert (strand.running_in_this_thread ());
 | 
				
			||||||
	try
 | 
						try
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		co_await run_sending (condition);
 | 
							co_await run_sending (condition);
 | 
				
			||||||
| 
						 | 
					@ -48,7 +55,6 @@ void nano::transport::tcp_channel::start ()
 | 
				
			||||||
		debug_assert (ex.code () == asio::error::operation_aborted);
 | 
							debug_assert (ex.code () == asio::error::operation_aborted);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	debug_assert (strand.running_in_this_thread ());
 | 
						debug_assert (strand.running_in_this_thread ());
 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nano::transport::tcp_channel::stop ()
 | 
					void nano::transport::tcp_channel::stop ()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,7 @@ private:
 | 
				
			||||||
	void start ();
 | 
						void start ();
 | 
				
			||||||
	void stop ();
 | 
						void stop ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						asio::awaitable<void> start_sending (nano::async::condition &);
 | 
				
			||||||
	asio::awaitable<void> run_sending (nano::async::condition &);
 | 
						asio::awaitable<void> run_sending (nano::async::condition &);
 | 
				
			||||||
	asio::awaitable<void> send_one (traffic_type, tcp_channel_queue::entry_t const &);
 | 
						asio::awaitable<void> send_one (traffic_type, tcp_channel_queue::entry_t const &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue