Skip to content

Commit

Permalink
Adjust thread pool priority
Browse files Browse the repository at this point in the history
  • Loading branch information
p-lr committed Nov 19, 2019
1 parent fe73a19 commit 75e8ce0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[ ![Download](https://api.bintray.com/packages/peterlaurence/maven/mapview/images/download.svg?version=1.0.6) ](https://bintray.com/peterlaurence/maven/mapview/1.0.6/link)
[ ![Download](https://api.bintray.com/packages/peterlaurence/maven/mapview/images/download.svg?version=1.0.7) ](https://bintray.com/peterlaurence/maven/mapview/1.0.7/link)

# MapView

Expand Down Expand Up @@ -29,7 +29,7 @@ This project holds the source code of this library, plus a demo app (which is us

Add this to your module's build.gradle
```groovy
implementation 'com.peterlaurence:mapview:1.0.6'
implementation 'com.peterlaurence:mapview:1.0.7'
```

## Origin and motivation
Expand Down
4 changes: 2 additions & 2 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlinx-serialization'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.peterlaurence.mapview.demo"
minSdkVersion 23
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
8 changes: 4 additions & 4 deletions mapview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlinx-serialization'

def version = "1.0.6"
def version = "1.0.7"

androidExtensions {
experimental = true
Expand All @@ -20,12 +20,12 @@ buildscript {
}

android {
compileSdkVersion 28
compileSdkVersion 29


defaultConfig {
minSdkVersion 23
targetSdkVersion 28
targetSdkVersion 29
versionCode 2
versionName version
}
Expand Down Expand Up @@ -54,7 +54,7 @@ dependencies {

implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'org.robolectric:robolectric:4.3.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ class TileCollector(private val workerCount: Int) {
SynchronousQueue<Runnable>(), ThreadFactory { r ->
Thread(r).apply {
isDaemon = true
priority = Thread.MIN_PRIORITY
Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST)
/* Beware, using THREAD_PRIORITY_LOWEST leads to UI hang on some emulators, while
* THREAD_PRIORITY_BACKGROUND has similar positive impact on overall responsiveness on
* low-end devices while not having this side effect. */
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND)
}
}).asCoroutineDispatcher()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.peterlaurence.mapview.core

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Build
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
Expand All @@ -13,6 +14,7 @@ import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import java.io.File
import java.io.FileInputStream
import java.io.InputStream
Expand All @@ -26,6 +28,7 @@ import com.peterlaurence.mapview.core.TileStreamProvider as MapViewTileStreamPro
* * The [Bitmap] of the [Tile]s produced should be consistent with the output of the flow
*/
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [Build.VERSION_CODES.P])
class TileCollectorTest {

private val tileSize = 256
Expand Down

0 comments on commit 75e8ce0

Please sign in to comment.