#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,19 +1,20 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/
package source;
@@ -24,63 +25,60 @@ import source.mixer.MixerManager;
import source.recording.RecordingSourceManager;
import source.tuner.TunerManager;
import source.tuner.TunerModel;
import controller.ThreadPoolManager;
public class SourceManager
public class SourceManager
{
private MixerManager mMixerManager;
private RecordingSourceManager mRecordingSourceManager;
private TunerManager mTunerManager;
private TunerModel mTunerModel;
private MixerManager mMixerManager;
private RecordingSourceManager mRecordingSourceManager;
private TunerManager mTunerManager;
private TunerModel mTunerModel;
public SourceManager( TunerModel tunerModel,
SettingsManager settingsManager,
ThreadPoolManager threadPoolManager )
{
mTunerModel = tunerModel;
mMixerManager = new MixerManager();
mRecordingSourceManager = new RecordingSourceManager( settingsManager );
mTunerManager = new TunerManager( mMixerManager, tunerModel, threadPoolManager );
//TODO: change mixer & recording managers to be models and hand them
//in via the constructor. Perform loading outside of this class.
}
public MixerManager getMixerManager()
{
return mMixerManager;
}
public SourceManager(TunerModel tunerModel, SettingsManager settingsManager)
{
mTunerModel = tunerModel;
mMixerManager = new MixerManager();
mRecordingSourceManager = new RecordingSourceManager(settingsManager);
mTunerManager = new TunerManager(mMixerManager, tunerModel);
public RecordingSourceManager getRecordingSourceManager()
{
return mRecordingSourceManager;
}
public TunerManager getTunerManager()
{
return mTunerManager;
}
public Source getSource( SourceConfiguration config, int bandwidth )
throws SourceException
{
Source retVal = null;
//TODO: change mixer & recording managers to be models and hand them
//in via the constructor. Perform loading outside of this class.
}
switch( config.getSourceType() )
{
case MIXER:
retVal = mMixerManager.getSource( config );
break;
case TUNER:
retVal = mTunerModel.getSource( (SourceConfigTuner)config, bandwidth );
break;
case RECORDING:
retVal = mRecordingSourceManager.getSource( config, bandwidth );
case NONE:
default:
break;
}
return retVal;
}
public MixerManager getMixerManager()
{
return mMixerManager;
}
public RecordingSourceManager getRecordingSourceManager()
{
return mRecordingSourceManager;
}
public TunerManager getTunerManager()
{
return mTunerManager;
}
public Source getSource(SourceConfiguration config, int bandwidth)
throws SourceException
{
Source retVal = null;
switch(config.getSourceType())
{
case MIXER:
retVal = mMixerManager.getSource(config);
break;
case TUNER:
retVal = mTunerModel.getSource((SourceConfigTuner) config, bandwidth);
break;
case RECORDING:
retVal = mRecordingSourceManager.getSource(config, bandwidth);
case NONE:
default:
break;
}
return retVal;
}
}