using System;
using AsterNET.FastAGI;
namespace AsterNET.Util
{
///
/// A TaskThread sits in a loop, asking the pool for a job, and servicing it.
///
internal class ThreadTask : ThreadClass
{
private ThreadPool threadPool;
#region ThreadPool
public ThreadPool ThreadPool
{
get { return threadPool; }
}
#endregion
#region ThreadTask(ThreadPool enclosingInstance, string name)
public ThreadTask(ThreadPool enclosingInstance, string name)
: base(name)
{
this.threadPool = enclosingInstance;
}
#endregion
#region Run()
///
/// Get a job from the pool, run it, repeat. If the obtained job is null, we exit the loop and the thread.
///
public override void Run()
{
while (true)
{
AGIConnectionHandler job = ThreadPool.obtainJob();
if (job == null)
break;
job.Run();
}
}
#endregion
}
}