blob: d5a46de980f9562ea70f995dd3a092f2b5161f31 [file] [log] [blame]
Jorim Jaggifabc7432017-05-15 02:40:05 +02001/*
2 * Copyright (C) 2017 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
Dave Mankoffc7cf9fc2019-12-19 15:43:20 -050014 * limitations under the License.
Jorim Jaggifabc7432017-05-15 02:40:05 +020015 */
16
17package com.android.systemui;
18
19import java.util.concurrent.ExecutorService;
20import java.util.concurrent.Executors;
21import java.util.concurrent.Future;
22
Jason Monk196d6392018-12-20 13:25:34 -050023import javax.inject.Inject;
24import javax.inject.Singleton;
25
Jorim Jaggifabc7432017-05-15 02:40:05 +020026/**
27 * Thread that offloads work from the UI thread but that is still perceptible to the user, so the
28 * priority is the same as the main thread.
29 */
Jason Monk196d6392018-12-20 13:25:34 -050030@Singleton
Jorim Jaggifabc7432017-05-15 02:40:05 +020031public class UiOffloadThread {
32
33 private final ExecutorService mExecutorService = Executors.newSingleThreadExecutor();
34
Jason Monk196d6392018-12-20 13:25:34 -050035 @Inject
36 public UiOffloadThread() {
37 }
38
Dave Mankoffc7cf9fc2019-12-19 15:43:20 -050039 public Future<?> execute(Runnable runnable) {
Jorim Jaggifabc7432017-05-15 02:40:05 +020040 return mExecutorService.submit(runnable);
41 }
42}