Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Commit

Permalink
Fixed tryAcquire bug for the serial port lock when updating the statu…
Browse files Browse the repository at this point in the history
…s at the top of the window (was causing some freezes).
  • Loading branch information
maxieds committed Jan 17, 2018
1 parent bc5e012 commit c0d72ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.maxieds.chameleonminilivedebugger"
minSdkVersion 21
targetSdkVersion 25
versionCode 21
versionName "0.2.5"
versionCode 23
versionName "0.2.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ChameleonIO {
* Default timeout to use when communicating with the device.
*/
public static final int TIMEOUT = 2000;
public static final int LOCK_TIMEOUT = 350;

/**
* Static constants for storing state of the device.
Expand Down Expand Up @@ -187,7 +188,10 @@ public void run() {
*/
private void updateAllStatus() {
try {
LiveLoggerActivity.serialPortLock.tryAcquire(ChameleonIO.TIMEOUT, TimeUnit.MILLISECONDS);
if(!LiveLoggerActivity.serialPortLock.tryAcquire(ChameleonIO.LOCK_TIMEOUT, TimeUnit.MILLISECONDS)) {
statsUpdateHandler.postDelayed(statsUpdateRunnable, STATS_UPDATE_INTERVAL / 4);
return;
}
} catch(InterruptedException ie) {
return;
}
Expand Down

0 comments on commit c0d72ec

Please sign in to comment.