drasys.or.util
Class Smp
java.lang.Object
|
+--drasys.or.util.Smp
- public class Smp
- extends java.lang.Object
Abstract base class for symmetrical multiprocessing concurrent algorithms.
Constructor Summary |
Smp(int minWork)
|
Smp(int maxThreads,
int minWork)
|
Method Summary |
int[] |
balanceTasks(int numTasks,
int workPerTask)
Split tasks into groups of equal work that meet the minimum work parameter. |
static int |
getDefaultMaxThreads()
Gets the default number of threads for Smp classes. |
static void |
schedule(int maxThreads,
java.lang.Runnable[] jobs,
long millis)
Schedules the jobs so that no more than 'maxThreads' are running at once. |
static void |
setDefaultMaxThreads(int defaultMaxThreads)
Sets the default number of threads for Smp classes. |
void |
setMaxThreads(int maxThreads)
Sets the maximum threads that can be assigned. |
void |
setMinWork(int minWork)
Stes the minimum work required in a thread before the next thread is assigned. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
_minWork
protected int _minWork
_maxThreads
protected int _maxThreads
Smp
public Smp(int minWork)
Smp
public Smp(int maxThreads,
int minWork)
getDefaultMaxThreads
public static int getDefaultMaxThreads()
- Gets the default number of threads for Smp classes.
This will typically be set to the number of processors in the system.
The default value for the default is '1';
setDefaultMaxThreads
public static void setDefaultMaxThreads(int defaultMaxThreads)
- Sets the default number of threads for Smp classes.
This will typically be set to the number of processors in the system.
The default value for the default is '1';
setMinWork
public void setMinWork(int minWork)
- Stes the minimum work required in a thread before the next thread is assigned.
This is used to insure that the thread overhead isn't more than the time savings.
setMaxThreads
public void setMaxThreads(int maxThreads)
- Sets the maximum threads that can be assigned.
balanceTasks
public int[] balanceTasks(int numTasks,
int workPerTask)
- Split tasks into groups of equal work that meet the minimum work parameter.
schedule
public static void schedule(int maxThreads,
java.lang.Runnable[] jobs,
long millis)
throws java.lang.InterruptedException
- Schedules the jobs so that no more than 'maxThreads' are running at once.
The jobs are started sequentially starting with '0'.
The threads should be ordered in descending amount of work.
- Parameters:
millis
- the maximum time any thread can be idle.
Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com