An asynchronous operation that can be waited on by a Coroutine.
When a Coroutine yields a Suspend function, it is called with a
Request. The Suspend function should arrange for the request to be
settled (via resolve or reject).
Note: If the request is not settled, the coroutine will be suspended until
cancelled by outside forces. (Such as its enclosing context cleaning up,
or explicit throw()/return() calls on the task's Work, or the
completion of another activity sharing the task's work context via
starting() or exec().)
Also note that any subtasks the Suspend function creates (or cleanup
callbacks it registers) will not be cleaned up until the calling task
ends. So any resources that won't be needed once the task is resumed
should be explicitly disposed of -- in which case you should probably just
yield * to a start(), instead of yielding a Suspend!
An asynchronous operation that can be waited on by a Coroutine.
When a Coroutine yields a Suspend function, it is called with a Request. The Suspend function should arrange for the request to be settled (via resolve or reject).
Note: If the request is not settled, the coroutine will be suspended until cancelled by outside forces. (Such as its enclosing context cleaning up, or explicit throw()/return() calls on the task's Work, or the completion of another activity sharing the task's work context via starting() or exec().)
Also note that any subtasks the Suspend function creates (or cleanup callbacks it registers) will not be cleaned up until the calling task ends. So any resources that won't be needed once the task is resumed should be explicitly disposed of -- in which case you should probably just
yield *to a start(), instead of yielding a Suspend!