-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2656 from square/py/stop_using_work_manager_inter…
…nals Stop using WorkManager internals
- Loading branch information
Showing
3 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
leakcanary/leakcanary-android-core/src/main/java/leakcanary/internal/LazyImmediateFuture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package leakcanary.internal | ||
|
||
import com.google.common.util.concurrent.ListenableFuture | ||
import java.util.concurrent.Executor | ||
import java.util.concurrent.TimeUnit | ||
|
||
internal class LazyImmediateFuture<V>( | ||
valueProvider: () -> V | ||
) : ListenableFuture<V> { | ||
|
||
private val value by lazy { | ||
valueProvider() | ||
} | ||
|
||
override fun cancel(mayInterruptIfRunning: Boolean) = false | ||
|
||
override fun isCancelled() = false | ||
|
||
override fun isDone() = true | ||
|
||
override fun get() = value | ||
|
||
override fun get( | ||
timeout: Long, | ||
unit: TimeUnit? | ||
): V = value | ||
|
||
override fun addListener( | ||
listener: Runnable, | ||
executor: Executor | ||
) { | ||
executor.execute(listener) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters