1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.camera.camera2.pipe.core 18 19 import android.os.Handler 20 import java.util.concurrent.Executor 21 import kotlinx.coroutines.CoroutineDispatcher 22 import kotlinx.coroutines.CoroutineScope 23 24 /** 25 * This collection pre-configured executors, dispatchers, and scopes that are used throughout this 26 * library. 27 */ 28 public class Threads( 29 public val globalScope: CoroutineScope, 30 public val blockingExecutor: Executor, 31 public val blockingDispatcher: CoroutineDispatcher, 32 public val backgroundExecutor: Executor, 33 public val backgroundDispatcher: CoroutineDispatcher, 34 public val lightweightExecutor: Executor, 35 public val lightweightDispatcher: CoroutineDispatcher, 36 camera2Handler: () -> Handler, 37 camera2Executor: () -> Executor 38 ) { <lambda>null39 private val _camera2Handler = lazy { camera2Handler() } <lambda>null40 private val _camera2Executor = lazy { camera2Executor() } 41 42 public val camera2Handler: Handler 43 get() = _camera2Handler.value 44 45 public val camera2Executor: Executor 46 get() = _camera2Executor.value 47 } 48