2013-01-18 15:55:50 +00:00
|
|
|
using System;
|
2014-01-08 14:16:39 +00:00
|
|
|
using AsterNET.FastAGI;
|
2013-01-18 15:55:50 +00:00
|
|
|
|
2014-01-08 14:16:39 +00:00
|
|
|
namespace AsterNET.Util
|
2013-01-18 15:55:50 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A TaskThread sits in a loop, asking the pool for a job, and servicing it.
|
|
|
|
/// </summary>
|
|
|
|
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()
|
|
|
|
/// <summary>
|
|
|
|
/// Get a job from the pool, run it, repeat. If the obtained job is null, we exit the loop and the thread.
|
|
|
|
/// </summary>
|
|
|
|
public override void Run()
|
|
|
|
{
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
AGIConnectionHandler job = ThreadPool.obtainJob();
|
|
|
|
if (job == null)
|
|
|
|
break;
|
|
|
|
job.Run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|