Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 4688fd89 authored by Jorge Gil's avatar Jorge Gil
Browse files

Provide @ShellMainThread dispatcher as MainCoroutineDispatcher

Changes the CoroutineDispatcher (and thus scope) for shell.main to a
MainCoroutineDispatcher backed by a Handler. This is because
Executor#asCoroutineDispatcher assumes the #execute will post the
runnable but ShellExecutor actually runs it immediately if already on
the same thread. Using Handler#asCoroutinesDispatcher doesn't have the
same problem because the backing Handler always uses #post to run the
Runnable.
CoroutineDispatchers already have this immediate vs posted functionality
built-in (see CoroutineDispatcher#isDispatchNeeded), and
MainCoroutineDispatcher#immediate is available to callers that want to
explicitly run coroutines in an immediate (non-dispatching) way.

Bug: None
Flag: EXEMPT bugfix
Test: m
Change-Id: I516351b93d103b59f8fa8d191f300122acdf9001
parent ec252cbd
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment