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

Commit 63765a85 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add @JvmStatic to kotlin util methods" into main

parents d2c3a4c3 000861fd
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -31,18 +31,21 @@ import java.util.concurrent.Executors
 */
 */
object LifecycleAwareExecutorFactory {
object LifecycleAwareExecutorFactory {


    @JvmStatic
    fun newSingleThreadExecutor(lifecycle: Lifecycle?): ExecutorService {
    fun newSingleThreadExecutor(lifecycle: Lifecycle?): ExecutorService {
        return Executors.newSingleThreadExecutor().also { executor ->
        return Executors.newSingleThreadExecutor().also { executor ->
            executor.autoShutdown(lifecycle)
            executor.autoShutdown(lifecycle)
        }
        }
    }
    }


    @JvmStatic
    fun newFixedThreadPool(lifecycle: Lifecycle?, nThreads: Int): ExecutorService {
    fun newFixedThreadPool(lifecycle: Lifecycle?, nThreads: Int): ExecutorService {
        return Executors.newFixedThreadPool(nThreads).also { executor ->
        return Executors.newFixedThreadPool(nThreads).also { executor ->
            executor.autoShutdown(lifecycle)
            executor.autoShutdown(lifecycle)
        }
        }
    }
    }


    @JvmStatic
    fun newCachedThreadPool(lifecycle: Lifecycle?): ExecutorService {
    fun newCachedThreadPool(lifecycle: Lifecycle?): ExecutorService {
        return Executors.newCachedThreadPool().also { executor ->
        return Executors.newCachedThreadPool().also { executor ->
            executor.autoShutdown(lifecycle)
            executor.autoShutdown(lifecycle)