Skip to content

parameter problem in coroutine functions #1708

Answered by VladlenPopolitov
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

When you take decision about reference parameter transfer, you have to consider the time of life for every parameter. You have to remember, that coroutines are not usual functions, they are created (coroutine handle and local memory allocated), called, returned execution to caller (looks like they sleep), resume again and again, and destroyed where they call co_return (handle and allocated variables memory destroyed and released).

  1. If you pass to custom coroutine reference to global variable, it will exists longer , then you custom coroutine, you can pass by reference. Anyway, this global variable can be deleted in other part of the program, you have to understand it.
  2. the same with static…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ghost
Comment options

@VladlenPopolitov
Comment options

Answer selected
@ghost
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants