From 231f8bfb92f8c9bfcbeae2890511dae28936a9b4 Mon Sep 17 00:00:00 2001 From: jlin16 Date: Tue, 20 Mar 2007 06:02:06 +0000 Subject: Create more threads to synchronize pcd data for FrameworkModules in a platform. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2489 6f19259b-4bc3-4df7-8a09-765794883524 --- .../platform/ui/FpdFileContents.java | 4 +- .../platform/ui/FpdFrameworkModules.java | 95 ++++++++++++++++------ 2 files changed, 71 insertions(+), 28 deletions(-) diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java index 4bca7fe22d..c5f854a7e8 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java @@ -494,7 +494,7 @@ public class FpdFileContents { return dataModified; } - private void maintainDynPcdMap(String pcdKey, String moduleInfo) { + private synchronized void maintainDynPcdMap(String pcdKey, String moduleInfo) { ArrayList al = dynPcdMap.get(pcdKey); if (al == null) { @@ -1318,7 +1318,7 @@ public class FpdFileContents { return choosedType; } - private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, + private synchronized void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa, PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd) throws PcdItemTypeConflictException, PcdValueMalFormed{ if (moduleSa.getPcdBuildDefinition() == null){ diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java index 902c12a17c..b8eb8c682b 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java @@ -59,6 +59,8 @@ public class FpdFrameworkModules extends IInternalFrame { private static final int timeToWait = 2000; + private static final int pcdSyncThreadNumber = 10; + private long savedMs = 0; String searchField = ""; @@ -838,9 +840,11 @@ public class FpdFrameworkModules extends IInternalFrame { private class PcdSyncTask extends Thread { + boolean pcdSynced = false; public void run () { Vector vExceptions = new Vector(); - if (pcdSync(vExceptions)) { + pcdSync(vExceptions); + if (pcdSynced) { JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), "PCD in this platform are synchronized with those in MSA files."); docConsole.setSaved(false); } @@ -852,6 +856,70 @@ public class FpdFrameworkModules extends IInternalFrame { JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), "Error occurred during synchronization:\n" + errorMsg); } } + + private void pcdSync(Vector v) { + + Vector vThreads = new Vector (); + int moduleCount = jTableFpdModules.getRowCount(); + int start = 0; + for (int i = 0; i < FpdFrameworkModules.pcdSyncThreadNumber; ++i) { + int end = start + moduleCount/FpdFrameworkModules.pcdSyncThreadNumber; + if (end > moduleCount) { + end = moduleCount; + } + vThreads.add(new PcdSyncSubTask (start, end, v)); + start = end; + } + + for (int i = 0; i < FpdFrameworkModules.pcdSyncThreadNumber; ++i) { + vThreads.get(i).start(); + } + + try { + for (int i = 0; i < FpdFrameworkModules.pcdSyncThreadNumber; ++i) { + vThreads.get(i).join(); + } + } + catch (InterruptedException e) { + + } + + } + + private class PcdSyncSubTask extends Thread { + + private int startModule = 0; + private int endModulePlusOne = 1; + private Vector v = null; + + PcdSyncSubTask (int start, int endPlusOne, Vector vErr) { + startModule = start; + endModulePlusOne = endPlusOne; + v = vErr; + } + + public void run () { + String[] sa = new String[5]; + for (int i = startModule; i < endModulePlusOne; ++i) { + try { + ffc.getFrameworkModuleInfo(i, sa); + String mg = sa[ffcModGuid]; + String mv = sa[ffcModVer]; + String pg = sa[ffcPkgGuid]; + String pv = sa[ffcPkgVer]; + String arch = sa[ffcModArch]; + String key = mg + " " + mv + " " + pg + " " + pv + " " + arch; + if (ffc.adjustPcd(key, v)) { + pcdSynced = true; + } + } + catch (Exception exp) { +// JOptionPane.showMessageDialog(frame, exp.getMessage()); + continue; + } + } + } + } } /** @@ -937,31 +1005,6 @@ public class FpdFrameworkModules extends IInternalFrame { } - private boolean pcdSync(Vector v) { - boolean synced = false; - String[] sa = new String[5]; - for (int i = 0; i < jTableFpdModules.getRowCount(); ++i) { - try { - ffc.getFrameworkModuleInfo(i, sa); - String mg = sa[ffcModGuid]; - String mv = sa[ffcModVer]; - String pg = sa[ffcPkgGuid]; - String pv = sa[ffcPkgVer]; - String arch = sa[ffcModArch]; - String key = mg + " " + mv + " " + pg + " " + pv + " " + arch; - if (ffc.adjustPcd(key, v)) { - synced = true; - } - } - catch (Exception exp) { -// JOptionPane.showMessageDialog(frame, exp.getMessage()); - continue; - } - } - return synced; - - } - private void showAllModules() { if (miList == null) { -- cgit v1.2.3