From: <jsa...@us...> - 2008-11-04 19:03:04
|
Revision: 54 http://flexotask.svn.sourceforge.net/flexotask/?rev=54&view=rev Author: jsauerbach Date: 2008-11-04 19:02:59 +0000 (Tue, 04 Nov 2008) Log Message: ----------- Initialize otherRunnables earlier so that the results will be visible earlier. With caveats as noted in the comment. Change submitted by Jia Zou Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java 2008-10-31 13:56:12 UTC (rev 53) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java 2008-11-04 19:02:59 UTC (rev 54) @@ -350,9 +350,14 @@ if (nRunnables > 1) { System.arraycopy(otherRunnables,0, runnables,1, nRunnables-1); } - /* Ensure that the otherThreads and otherRunnables arrays are pre-initialized so that they will be cloned */ + /* Ensure that the otherThreads and otherRunnables arrays are pre-initialized so that they will be cloned. The otherThreads array + * is not populated (the threads don't exist yet). The otherRunnables array is populated with the pre-cloned runnables, but the + * cloning operation should cause that to be updated upon cloning. */ if (nRunnables > 1) { toClone.otherRunnables = new FlexotaskSchedulerRunnable[nRunnables-1]; + for (int i = 0; i < nRunnables-1; i++) { + toClone.otherRunnables[i] = runnables[i + 1]; + } toClone.otherThreads = new Thread[nRunnables-1]; } /* Create the requested number of locks (at least one) to be pinned by the factory */ @@ -362,15 +367,15 @@ } /* Run the thread factory to obtain threads and clone the runnables */ Thread[] allThreads = threadFactory.createThreads(runnables, theLocks); - /* Stow the slave threads and cloned runnables in their rightful place in the cloned master runnable */ + /* Stow the slave threads in their rightful place in the cloned master runnable. The runnables are already in their rightful + * place due to cloning. */ FlexotaskSingleThreadRunner clonedMasterRunnable = (FlexotaskSingleThreadRunner) runnables[0]; if (nRunnables > 1) { for (int i = 0; i < nRunnables-1; i++) { - clonedMasterRunnable.otherRunnables[i] = runnables[i + 1]; clonedMasterRunnable.otherThreads[i] = allThreads[i + 1]; } } - /* Start the master thread (only) */ + /* Start all threads */ for (int i = 0; i < nRunnables; i++) { allThreads[i].start(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |