Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
470727 - Thread Starvation with EWYK
Added constructor to allow low resources strategy to be pluggable within EWYK
  • Loading branch information
gregw committed Jul 3, 2015
1 parent 75fc82b commit 83fcdda
Showing 1 changed file with 9 additions and 2 deletions.
Expand Up @@ -54,14 +54,19 @@ public class ExecuteProduceConsume implements ExecutionStrategy, Runnable
private boolean _producing;
private boolean _pending;
private final ThreadPool _threadpool;
private final ProduceExecuteConsume _lowresources;
private final ExecutionStrategy _lowresources;

public ExecuteProduceConsume(Producer producer, Executor executor)
{
this(producer,executor,(executor instanceof ThreadPool)?new ProduceExecuteConsume(producer,executor):null);
}

public ExecuteProduceConsume(Producer producer, Executor executor, ExecutionStrategy lowResourceStrategy)
{
this._producer = producer;
this._executor = executor;
_threadpool = (executor instanceof ThreadPool)?((ThreadPool)executor):null;
_lowresources = _threadpool==null?null:new ProduceExecuteConsume(producer,executor);
_lowresources = _threadpool==null?null:lowResourceStrategy;
}

@Override
Expand Down Expand Up @@ -137,6 +142,8 @@ public void run()
LOG.debug("EWYK low resources {}",this);
_lowresources.execute();
}

// no longer low resources so produceAndRun normally
produceAndRun();
}
}
Expand Down

0 comments on commit 83fcdda

Please sign in to comment.