Skip to content
Permalink
Browse files

appmonitor: dont execute exportData() in its own thread

Executing this in its own thread while continue with the normal
operations might be a stupid idea, since it will increase the
system load for a short amount of time.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
  • Loading branch information
Blechd0se committed Oct 21, 2015
1 parent 38c405d commit c3d913921e6e16ddb026fe3f2df6b65196be31ef
@@ -44,7 +44,7 @@ public Configuration() {}
public static final int EXPORT_THRESHOLD = 60000;

/**
* If true, the import/export of data will be in a separate thread.
* If true, the import of data will be in a separate thread.
*/
public static final boolean THREADED_IMPORT_EXPORT = true;
public static final boolean THREADED_IMPORT = true;
}
@@ -23,7 +23,6 @@

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -64,7 +63,7 @@ private JobManager(Context context) {
this.mAppModuleData = new AppModuleData(getModules());

// If necessary load the saved raw data back in;
if (Configuration.THREADED_IMPORT_EXPORT) {
if (Configuration.THREADED_IMPORT) {
Runnable run = new Runnable() {
@Override
public void run() {
@@ -274,8 +273,10 @@ public void exportData() {

AppLogger.print(mClassName, "Starting export for: " + context.getAppName(), 1);

List<AppModuleMetaData> moduleMetaData = getModuleData().getAppModuleData();

// Get the meta data for all loaded modules;
for (AppModuleMetaData ammd : getModuleData().getAppModuleData()) {
for (AppModuleMetaData ammd : moduleMetaData) {
// Find our App context;
if (ammd.getAppContext() == context) {

@@ -287,7 +288,7 @@ public void exportData() {
// For each module we need to get the data separately;
JSONObject appModule = new JSONObject();
// Our actual values are stored in this array;
JSONArray values = new JSONArray();
JSONArray values = new JSONArray();

AppLogger.print(mClassName, "Adding Data for module: " + module.getName(), 1);

@@ -480,18 +481,7 @@ public final void schedule(final AppContext context) {
// If we are above the threshold, export data and set a new threshold;
if (System.currentTimeMillis() > mExportThreshold ) {

if (Configuration.THREADED_IMPORT_EXPORT) {
Runnable run = new Runnable() {
@Override
public void run() {
exportData();
}
};
Thread worker = new Thread(run);
worker.start();
} else {
exportData();
}
exportData();

setExportTimeNow();
}

0 comments on commit c3d9139

Please sign in to comment.
You can’t perform that action at this time.