Bah humbug
This commit is contained in:
parent
a89a6927e8
commit
fd605248dc
|
@ -56,6 +56,37 @@ public interface ExecutionStrategy
|
|||
Runnable produce();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>A strategy where the caller thread iterates over task production, submitting each
|
||||
* task to an {@link Executor} for execution.</p>
|
||||
*/
|
||||
public static class ProduceRun implements ExecutionStrategy
|
||||
{
|
||||
private final Producer _producer;
|
||||
|
||||
public ProduceRun(Producer producer)
|
||||
{
|
||||
this._producer = producer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
// Iterate until we are complete.
|
||||
while (true)
|
||||
{
|
||||
// Produce a task.
|
||||
Runnable task = _producer.produce();
|
||||
|
||||
if (task == null)
|
||||
break;
|
||||
|
||||
// run the task.
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>A strategy where the caller thread iterates over task production, submitting each
|
||||
* task to an {@link Executor} for execution.</p>
|
||||
|
|
Loading…
Reference in New Issue