|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace NParallel.Core
{
public class NQueue
{
NMarshal marshal = NMarshal.Auto;
List<INResult> list = new List<INResult>();
static NQueue instance = new NQueue();
public NMarshal DefaultMarshal
{
get
{
return marshal;
}
set
{
marshal = value;
}
}
NQueue()
{
}
public bool Empty
{
get
{
return list.Count == 0;
}
}
public static NQueue Instance
{
get
{
return instance;
}
}
public void EnQueue(INResult result)
{
list.Add(result);
}
public void Update()
{
foreach (INResult var in list)
{
if (! var.IsDone())
{
var.Complete();
var.DoCallback();
}
}
list.RemoveAll(delegate(INResult result)
{
return result.IsDone();
});
}
//public bool BindCallback(DelegateVoid method, DelegateVoid callback)
//{
// return BindCallbackImpl(method, callback);
//}
//public bool BindCallback<T>(TDelegate<T> method, TResultDel<T> callback)
//{
// return BindCallbackImpl(method , callback);
//}
//bool BindCallbackImpl(object method, object callback)
//{
// Debug.Assert(method != null && callback != null);
// if (callbacks.ContainsKey(method))
// {
// return false;
// }
// callbacks[method] = callback;
// return true;
//}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Leaf is a software developer based in ShangHai China.
My major programming languages are C#/C++.
I am very interested in distributed system design and rich client development.
Current I am working on
NParallel.