Fix shutdown deadlock (#9724)
Fix shutdown deadlock (#9724)

Fix shutdown deadlock in poller

The issue was that iree_task_poller_pump_until_exit only checked
for IREE_TASK_POLLER_STATE_EXITING at the beginning of each loop
iteration, then reset wake_event, then called
iree_task_poller_commit_wait.

Meanwhile, on the main thread, iree_task_poller_request_exit could
change state to IREE_TASK_POLLER_STATE_EXITING and set wake_event.

So in a race, iree_task_poller_pump_until_exit would reset the
wake_event set by iree_task_poller_request_exit, and that would leave
iree_task_poller_commit_wait waiting infinitely.

Fixes #9723

google/iree,iree-org/iree,google/iree,google/iree,iree-org/iree,iree-org/iree,google/iree,iree-org/iree,iree-org/iree,google/iree,google/iree,iree-org/iree,google/iree,iree-org/iree