Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d025244

Browse files
author
Davide Faconti
committed
more comments
1 parent ba3f66f commit d025244

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

docs/tutorial_H_coroutines.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MyAsyncAction: public CoroActionNode
3838
// Call setStatusRunningAndYield() to "pause".
3939
// - Code to execute after the reply.
4040
// - a simple way to handle halt().
41-
41+
4242
NodeStatus tick() override
4343
{
4444
std::cout << name() <<": Started. Send Request to server." << std::endl;
@@ -53,10 +53,13 @@ class MyAsyncAction: public CoroActionNode
5353

5454
if( !reply_received )
5555
{
56-
// set status to RUNNING and "pause/sleep"
56+
// set status to RUNNING and "pause/sleep"
57+
// If halt() is called, we will not resume execution
5758
setStatusRunningAndYield();
5859
}
5960
}
61+
62+
// this part of the code is never reached if halt() is invoked.
6063
std::cout << name() <<": Done." << std::endl;
6164
return NodeStatus::SUCCESS;
6265
}

examples/t08_async_actions_coroutines.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ class MyAsyncAction: public CoroActionNode
3838
if( !reply_received )
3939
{
4040
// set status to RUNNING and "pause/sleep"
41+
// If halt() is called, we will not resume execution
4142
setStatusRunningAndYield();
4243
}
4344
}
4445

46+
// this part of the code is never reached if halt() is invoked.
4547
std::cout << name() <<": Done." << std::endl;
4648
return NodeStatus::SUCCESS;
4749
}
@@ -86,12 +88,10 @@ actionA: Started. Request service using async call
8688
actionA: Waiting reply
8789
actionA: Waiting reply
8890
actionA: Waiting reply
89-
actionA: Waiting reply
9091
actionA: Done
9192
actionB: Started. Request service using async call
9293
actionB: Waiting reply
9394
actionB: Waiting reply
9495
actionB: Waiting reply
95-
actionB: Waiting reply
9696
actionB: Done
9797
*/

0 commit comments

Comments
 (0)