# gpui: Check run_until readiness between main-thread runnables \(\#62220\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/38df25d54c6f3b3ad8b94312405a53978fd496fc)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 38df25d54c6f3b3ad8b94312405a53978fd496fc

Requested commit: 38df25d54c6f3b3ad8b94312405a53978fd496fc

Commit: 38df25d54c6f3b3ad8b94312405a53978fd496fc

Tree: 1e0e4dbfa0b5ff82ccd5b7c62d32c0d993fc76cf

Author: Anthony Eid

Committer: GitHub

## Message

```
gpui: Check run_until readiness between main-thread runnables (#62220)

`ThreadedDispatcher::run_until` - the completion mechanism under
`BenchAppContext` async task benchmarks (`bench_task` /
`bench_batched_task`, added in #62180) - drained the entire main queue
before checking its readiness predicate. Main-thread work that re-queues
itself (an idle-time sweep, a polling loop) keeps the queue non-empty
until it finishes every iteration, so a task benchmark's measured
interval silently extended past the awaited task's completion until all
such deferred work settled. Benchmarks of UI workloads that schedule
follow-up idle work could report several times their true completion
latency.

This changes `run_until` to step main-thread runnables one at a time and
check readiness before each, so it returns at the completion it awaits
rather than at queue quiescence, making async task benchmarks more
accurate. The regression test spawns a task that re-queues itself 10,000
times plus a one-shot completion task, and asserts `run_until` returns
without draining the re-queued work; it fails against the previous
drain-first implementation.

Release Notes:

- N/A
```

## Parents

- [02c6dd95c44b1eac2bcff2e777e04d96a3e530cd](https://git.cafe/gitcafe/zed/commit/02c6dd95c44b1eac2bcff2e777e04d96a3e530cd?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/38df25d54c6f3b3ad8b94312405a53978fd496fc?format=markdown)
