1 /** 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * ``` 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * ``` 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package com.android.healthconnect.controller.service 15 16 import dagger.Module 17 import dagger.Provides 18 import dagger.hilt.InstallIn 19 import dagger.hilt.components.SingletonComponent 20 import javax.inject.Qualifier 21 import kotlinx.coroutines.CoroutineDispatcher 22 import kotlinx.coroutines.Dispatchers 23 24 @Module 25 @InstallIn(SingletonComponent::class) 26 object DispatcherModule { 27 @DefaultDispatcher 28 @Provides providesDefaultDispatchernull29 fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default 30 31 @IoDispatcher @Provides fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO 32 33 @MainDispatcher @Provides fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main 34 } 35 36 @Retention(AnnotationRetention.BINARY) @Qualifier annotation class DefaultDispatcher 37 38 @Retention(AnnotationRetention.BINARY) @Qualifier annotation class IoDispatcher 39 40 @Retention(AnnotationRetention.BINARY) @Qualifier annotation class MainDispatcher 41