solaza
solaza

Reputation: 1291

Kotlin Coroutines choosing Dispatcher

I'm trying to figure out which Dispatcher to use in what case.

I read some documentation and came up with this:

Is this right?

What about Unconfined?

Upvotes: 12

Views: 3478

Answers (1)

Andrei Tanana
Andrei Tanana

Reputation: 8422

You're right in your assumptions about the dispatcher types. Unconfined dispatcher –

A coroutine dispatcher that is not confined to any specific thread

Unconfined dispatcher is appropriate when coroutine does not consume CPU time nor updates any shared data (like UI) that is confined to a specific thread.

You can read more about it here and here

Upvotes: 6

Related Questions