Skip to content

The name for the main Android dispatcher #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
elizarov opened this issue Sep 7, 2018 · 4 comments
Closed

The name for the main Android dispatcher #533

elizarov opened this issue Sep 7, 2018 · 4 comments

Comments

@elizarov
Copy link
Contributor

elizarov commented Sep 7, 2018

We should finalize the name for the main Android dispatcher for 1.0 release of coroutines. The current name is UI, but Android documentation names the corresponding concept "the main thread" (see also here #427 (comment)). Arguably, with structured concurrency (see #410) this name would not be used much often, but we still need to make sure it is clearly named.

@JakeWharton
Copy link
Contributor

I strongly prefer MainThread for a few reasons:

  • The main thread is not always the UI thread
  • The main thread is still needed in locations like application subtypes, services, brodcast receivers, job scheduler jobs, etc. where there is no UI to speak of.

@fvasco
Copy link
Contributor

fvasco commented Sep 7, 2018

I agree with @JakeWharton

it's possible for a UI thread to be different from the main thread in the case of system apps with multiple views on different threads. Therefore, you should annotate methods associated with an app's view hierarchy with @ UiThread and annotate only methods associated with an app's lifecycle with @ MainThread.

https://developer.android.com/studio/write/annotations#thread-annotations

Currently Android integration uses the Main thread.
Moreover it is better use "Main" instead of "UI" here

@objcode
Copy link
Contributor

objcode commented Sep 8, 2018

Seconding Main which matches existing APIs (https://developer.android.com/reference/android/os/Looper#getMainLooper()) and is more accurate.

@elizarov
Copy link
Contributor Author

elizarov commented Sep 9, 2018

While we are at it, lets reopen discussion #41 about structures for all dispatcher name. Now, when we are about to release structured concurrency (#410) you would not have to mention the dispatcher names too often, so it makes sense to group them all.

elizarov added a commit that referenced this issue Sep 11, 2018
* Dispatchers.Default — a default dispatcher for background asynchronous tasks
  (currently backed by FJP commonPool, a new dispatcher in the future).
* Dispatchers.IO — a dispatcher for blocking background operations (#79).
* Dispatchers.Main — a dispatcher for Android Main Thread (#533).
* Dispatchers.Swing — a dispatcher for Swing Event Dispatch Thread.
* Dispatchers.JavaFx — a dispatcher for JavaFx Application Thread.
* Old dispatchers are deprecated, CommonPool is deprecated, too.
* awaitPulse() in JavaFx and awaitFrame() in Android are top-level funs.
* Introduced HandlerDispatcher, SwingDispatcher, and JavaFxDispatcher types
  in the corresponding UI modules for type-safety and future extensions

Fixes #41
elizarov added a commit that referenced this issue Sep 11, 2018
* Dispatchers.Default — a default dispatcher for background asynchronous tasks
  (currently backed by FJP commonPool, a new dispatcher in the future).
* Dispatchers.IO — a dispatcher for blocking background operations (#79).
* Dispatchers.Main — a dispatcher for Android Main Thread (#533).
* Dispatchers.Swing — a dispatcher for Swing Event Dispatch Thread.
* Dispatchers.JavaFx — a dispatcher for JavaFx Application Thread.
* Old dispatchers are deprecated, CommonPool is deprecated, too.
* awaitPulse() in JavaFx and awaitFrame() in Android are top-level funs.
* Introduced HandlerDispatcher, SwingDispatcher, and JavaFxDispatcher types
  in the corresponding UI modules for type-safety and future extensions

Fixes #41
Fixes #533
elizarov added a commit that referenced this issue Sep 11, 2018
* Dispatchers.Default — a default dispatcher for background asynchronous tasks
  (currently backed by FJP commonPool, a new dispatcher in the future).
* Dispatchers.IO — a dispatcher for blocking background operations (#79).
* Dispatchers.Main — a dispatcher for Android Main Thread (#533).
* Dispatchers.Swing — a dispatcher for Swing Event Dispatch Thread.
* Dispatchers.JavaFx — a dispatcher for JavaFx Application Thread.
* Old dispatchers are deprecated, CommonPool is deprecated, too.
* awaitPulse() in JavaFx and awaitFrame() in Android are top-level funs.
* Introduced HandlerDispatcher, SwingDispatcher, and JavaFxDispatcher types
  in the corresponding UI modules for type-safety and future extensions

Fixes #41
Fixes #533
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants