This is needed to ensure that pending updates are not lost due to the following scenario:
- The loop executes the last iteration
- There is more than one pending update or there is 1 pending update, but another is received when runAnActivityOrChildWorkflow is executing.
- The workflow continues as new, losing all the unprocessed pending updates.
The sample code processes all pending updates even if their number exceeds the number of iterations. There is also a guarantee that updates are not lost due to a race condition between the update and the workflow calling continue-as-new. This is achieved by ensuring that the signal handler is always invoked before the main workflow coroutine is unblocked.