X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/d15e99b4b543defc24b1fe66bf8f4c9421166a88..5120f3cb5e1678e7a142e00f463b502427f60c88:/trunk/Pithos.Core/JobQueue.cs diff --git a/trunk/Pithos.Core/JobQueue.cs b/trunk/Pithos.Core/JobQueue.cs index 78aa206..cca4a07 100644 --- a/trunk/Pithos.Core/JobQueue.cs +++ b/trunk/Pithos.Core/JobQueue.cs @@ -48,5 +48,35 @@ namespace Pithos.Core _statusUpdateQueue.CompleteAdding(); } + } + + public class JobAgent:Agent + { + protected JobAgent(Action> action) + :base(action) + { + + } + + public static JobAgent Create() + { + return (JobAgent)Start(queue => + { + Action loop = null; + loop = () => + { + var job = queue.Receive(); + job.ContinueWith(t => + { + t.IgnoreExceptions(); + var action = job.Result; + action(); + queue.DoAsync(loop); + }); + }; + loop(); + }); + } + } }