#108 [WIP] Created new ThreadPool class with a static ScheduledThreadExecutor that is now shared by all components. Removed ThreadPoolManager from all classes. Consolidating into 1 pool seems to have reduced CPU usage by ~15-20%. Overall memory usage is also reduced.

This commit is contained in:
Denny
2017-01-22 09:33:47 -05:00
parent 523ac0314e
commit 6e94d9ce51
39 changed files with 8822 additions and 9118 deletions

View File

@@ -1,83 +1,77 @@
package instrument.gui;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import alias.AliasModel;
import audio.broadcast.BroadcastModel;
import controller.channel.ChannelModel;
import controller.channel.map.ChannelMapModel;
import module.decode.DecodeConfigurationEditor;
import net.miginfocom.swing.MigLayout;
import playlist.PlaylistManager;
import source.IControllableFileSource;
import alias.AliasModel;
import controller.ThreadPoolManager;
import controller.channel.ChannelModel;
import controller.channel.map.ChannelMapModel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DecoderSelectionFrame extends JInternalFrame
{
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private DecodeConfigurationEditor mDecodeEditor = new DecodeConfigurationEditor( null );
private PlaylistManager mPlaylistManager;
private IControllableFileSource mSource;
private JDesktopPane mDesktop;
public DecoderSelectionFrame( JDesktopPane desktop,
IControllableFileSource source )
{
ThreadPoolManager tpm = new ThreadPoolManager();
private DecodeConfigurationEditor mDecodeEditor = new DecodeConfigurationEditor(null);
private PlaylistManager mPlaylistManager;
AliasModel aliasModel = new AliasModel();
BroadcastModel broadcastModel = new BroadcastModel(tpm, null);
ChannelModel channelModel = new ChannelModel();
ChannelMapModel channelMapModel = new ChannelMapModel();
private IControllableFileSource mSource;
private JDesktopPane mDesktop;
mPlaylistManager = new PlaylistManager( tpm, aliasModel, broadcastModel, channelModel, channelMapModel );
public DecoderSelectionFrame(JDesktopPane desktop,
IControllableFileSource source)
{
AliasModel aliasModel = new AliasModel();
BroadcastModel broadcastModel = new BroadcastModel(null);
ChannelModel channelModel = new ChannelModel();
ChannelMapModel channelMapModel = new ChannelMapModel();
mDesktop = desktop;
mSource = source;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "", "[grow,fill]", "[][][grow,fill]" ) );
mPlaylistManager = new PlaylistManager(aliasModel, broadcastModel, channelModel, channelMapModel);
setTitle( "Decoders" );
setPreferredSize( new Dimension( 700, 450 ) );
setSize( 700, 450 );
mDesktop = desktop;
mSource = source;
setResizable( true );
setClosable( true );
setIconifiable( true );
setMaximizable( false );
initGUI();
}
add( mDecodeEditor, "wrap" );
add( new AddDecoderButton(), "span" );
}
public class AddDecoderButton extends JButton
{
private static final long serialVersionUID = 1L;
private void initGUI()
{
setLayout(new MigLayout("", "[grow,fill]", "[][][grow,fill]"));
public AddDecoderButton()
{
super( "Add" );
addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
setTitle("Decoders");
setPreferredSize(new Dimension(700, 450));
setSize(700, 450);
setResizable(true);
setClosable(true);
setIconifiable(true);
setMaximizable(false);
add(mDecodeEditor, "wrap");
add(new AddDecoderButton(), "span");
}
public class AddDecoderButton extends JButton
{
private static final long serialVersionUID = 1L;
public AddDecoderButton()
{
super("Add");
addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0)
{
// DecodeConfiguration config = mDecodeEditor.getDecodeConfig();
//
// if( config != null )
@@ -89,9 +83,9 @@ public class DecoderSelectionFrame extends JInternalFrame
//
// mDesktop.add( decoderFrame );
// }
}
} );
}
}
}
});
}
}
}