using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Diagnostics;

namespace nft.framework {
    public delegate IEnumerable FiberTask();
    /// <summary>
    /// ノンプリエンプティブマルチタスク
    /// </summary>
    public class FiberManager {
        List<IEnumerator> fibers = new List<IEnumerator>();
        public int ProcessFibers() {
            for (int i = fibers.Count - 1; i >= 0; i--) {
                IEnumerator en = fibers[i];
                if (!en.MoveNext()) {
                    fibers.RemoveAt(i);
                }
            }
            return fibers.Count;
        }

        public void Add(IEnumerable fiberproc) {
            fibers.Add(fiberproc.GetEnumerator());
        }
    }

}
