mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-27 10:40:29 +00:00
8372048: Performance improvement on Linux remote desktop
Reviewed-by: azvegint, serb
This commit is contained in:
parent
d2926dfd9a
commit
0b3df489e9
@ -63,9 +63,11 @@ public final class ScreencastHelper {
|
||||
private static final int DELAY_BEFORE_SESSION_CLOSE = 2000;
|
||||
|
||||
private static volatile TimerTask timerTask = null;
|
||||
private static final Timer timerCloseSession
|
||||
= new Timer("auto-close screencast session", true);
|
||||
|
||||
private static class TimerHolder {
|
||||
private static final Timer timerCloseSession =
|
||||
new Timer("auto-close screencast session", true);
|
||||
}
|
||||
|
||||
private ScreencastHelper() {}
|
||||
|
||||
@ -143,7 +145,7 @@ public final class ScreencastHelper {
|
||||
}
|
||||
};
|
||||
|
||||
timerCloseSession.schedule(timerTask, DELAY_BEFORE_SESSION_CLOSE);
|
||||
TimerHolder.timerCloseSession.schedule(timerTask, DELAY_BEFORE_SESSION_CLOSE);
|
||||
}
|
||||
|
||||
public static synchronized void getRGBPixels(
|
||||
|
||||
@ -238,6 +238,7 @@ final class TokenStorage {
|
||||
}
|
||||
|
||||
private static WatchService watchService;
|
||||
private static volatile boolean isWatcherThreadStarted = false;
|
||||
|
||||
private static void setupWatch() {
|
||||
try {
|
||||
@ -257,10 +258,6 @@ final class TokenStorage {
|
||||
"file watch %s\n", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (watchService != null) {
|
||||
new WatcherThread(watchService).start();
|
||||
}
|
||||
}
|
||||
|
||||
// called from native
|
||||
@ -337,7 +334,27 @@ final class TokenStorage {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void startWatcherThreadIfNeeded() {
|
||||
if (!isWatcherThreadStarted) {
|
||||
// not sure if the double-checked locking is actually needed here
|
||||
// the getTokens is only called from ScreencastHelper#getRGBPixels
|
||||
// and ScreencastHelper#remoteDesktop* methods (which are synchronized),
|
||||
// but it may change later.
|
||||
synchronized (TokenStorage.class) {
|
||||
if (!isWatcherThreadStarted) {
|
||||
readTokens(PROPS_PATH);
|
||||
if (watchService != null) {
|
||||
new WatcherThread(watchService).start();
|
||||
}
|
||||
isWatcherThreadStarted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Set<TokenItem> getTokens(List<Rectangle> affectedScreenBounds) {
|
||||
startWatcherThreadIfNeeded();
|
||||
|
||||
// We need an ordered set to store tokens
|
||||
// with exact matches at the beginning.
|
||||
LinkedHashSet<TokenItem> result = new LinkedHashSet<>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user