Zesstra | 3085c66 | 2025-08-02 18:31:10 +0200 | [diff] [blame] | 1 | NAME |
| 2 | await |
| 3 | |
| 4 | SYNTAX |
| 5 | await(<coroutine>) |
| 6 | await(<coroutine>, <value>) |
| 7 | |
| 8 | DESCRIPTION |
| 9 | The instruction is only allowed in a coroutine and suspends its |
| 10 | execution. |
| 11 | |
| 12 | The target coroutine must also be in a suspended state. Its |
| 13 | execution will then continue. |
| 14 | |
| 15 | The current coroutine will wait for the execution of the target |
| 16 | coroutine to finish with a return statement or end of statement |
| 17 | block. It cannot continue its execution until then. Only one |
| 18 | coroutine may wait for another. If there is already a coroutine |
| 19 | waiting for the target coroutine the instruction will fail. |
| 20 | |
| 21 | Any calls during the waiting period to continue the current |
| 22 | coroutine will result in execution of the target coroutine. |
| 23 | So the await() call can be seen as a sub-coroutine call. |
| 24 | |
| 25 | The value will be passed into the target coroutine as the result |
| 26 | of its yield() instruction that suspended its execution before. |
| 27 | If the coroutine had just started, the value will be discarded. |
| 28 | If no value was given, 0 will be passed instead. |
| 29 | |
| 30 | HISTORY |
| 31 | Coroutines were introduced in LDMud 3.6.5. |
| 32 | |
| 33 | SEE ALSO |
| 34 | coroutines(LPC), async(LPC), yield(LPC), foreach(LPC), |
| 35 | call_coroutine(E), this_coroutine(E) |