Allow only one binding preview evaluator thread to make sure we don't hit online resources more than once (i.e. 2 threads requesting the same data at the same time)

This commit is contained in:
Reinhard Pointner 2017-01-10 00:45:12 +08:00
parent 029f3d9039
commit b4e9e67f6c
3 changed files with 3 additions and 4 deletions

View File

@ -356,7 +356,7 @@ class BindingDialog extends JDialog {
private final List<Evaluator> model = new ArrayList<Evaluator>();
private final ExecutorService executor = Executors.newFixedThreadPool(2, new DefaultThreadFactory("Evaluator", Thread.MIN_PRIORITY));
private final ExecutorService executor = Executors.newFixedThreadPool(1, new DefaultThreadFactory("Evaluator", Thread.MIN_PRIORITY));
public void setModel(Collection<String> expressions, Object bindingBean) {
// cancel old workers and clear model

View File

@ -72,7 +72,6 @@ import net.filebot.util.ui.GradientStyle;
import net.filebot.util.ui.LazyDocumentListener;
import net.filebot.util.ui.LinkButton;
import net.filebot.util.ui.ProgressIndicator;
import net.filebot.util.ui.SwingUI;
import net.filebot.util.ui.notification.SeparatorBorder;
import net.filebot.util.ui.notification.SeparatorBorder.Position;
import net.filebot.web.AudioTrackFormat;
@ -443,7 +442,7 @@ public class FormatDialog extends JDialog {
ExpressionFormat format = new ExpressionFormat(editor.getText().trim());
// activate delayed to avoid flickering when formatting takes only a couple of milliseconds
Timer progressIndicatorTimer = SwingUI.invokeLater(400, () -> progressIndicator.setVisible(true));
Timer progressIndicatorTimer = invokeLater(400, () -> progressIndicator.setVisible(true));
// cancel old worker later
Future<String> obsoletePreviewFuture = currentPreviewFuture;

View File

@ -39,7 +39,7 @@ movie.example[5]: {home}/Media/{plex}
music.example[0]: {artist} - {t}
# simple artist - album - title
music.example[1]: {[y]} {artist} - {t}
# artist - title [crc32]
# artist - title [48.0 kHz]
music.example[2]: {n} - {t} {[audio.SamplingRateString]}
# artist - title [2ch, 128000]
music.example[3]: {pi.pad(2)} {n} - {t} {[af, audio.BitRate]}