Esempio n. 1
0
        public void ComputesFibonacci()
        {
            StringReader reader = new StringReader(Fibonacci.PreComputed);

            string line = null;
            IList  list = new ArrayList();

            while ((line = reader.ReadLine()) != null)
            {
                string [] parts = line.Split(":"[0]);
                if (parts.Length < 2)
                {
                    continue;
                }
                int    n    = Int32.Parse(parts[0]);
                string fibN = parts[1].Trim();
                list.Insert(n, fibN);
            }

            int groupsixe           = 2;
            int num                 = 10;
            FJTaskRunnerGroup group = new FJTaskRunnerGroup(groupsixe);
            Fibonacci         f     = new Fibonacci(num);

            group.Invoke(f);
            int result = f.GetAnswer();

            Assert.AreEqual(list[num], result.ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor called only during FJTaskRunnerGroup initialization
 /// </summary>
 protected internal FJTaskRunner(FJTaskRunnerGroup g)
 {
     deq           = VolatileTaskRef.NewArray(INITIAL_CAPACITY);
     barrier       = new Object();
     scanPriority_ = FJTaskRunnerGroup.DefaultScanPriority;
     group_        = g;
     victimRNG     = new Random(this.GetHashCode());
 }
Esempio n. 3
0
        /// <summary>
        /// Create a new <see cref="FJTaskRunner"/>, setting its thread
        /// as needed
        /// </summary>
        public static FJTaskRunner New(FJTaskRunnerGroup runnerGroup)
        {
            FJTaskRunner runner = new FJTaskRunner(runnerGroup);
            Thread       t      = new Thread(new ThreadStart(runner.DoStart));

            t.Name = "FJTaskRunner thread #" + t.GetHashCode();
            runner.SetThread(t);
            return(runner);
        }
        public void ComputesFibonacci()
        {
            StringReader reader = new StringReader(Fibonacci.PreComputed);

            string line = null;
            IList list = new ArrayList();
            while ((line = reader.ReadLine()) != null)
            {
                string [] parts = line.Split(":"[0]);
                if (parts.Length < 2)
                    continue;
                int n = Int32.Parse(parts[0]);
                string fibN = parts[1].Trim();
                list.Insert(n, fibN);
            }

            int groupsixe=2;
            int num=10;
            FJTaskRunnerGroup group = new FJTaskRunnerGroup(groupsixe);
            Fibonacci f = new Fibonacci(num);
            group.Invoke(f);
            int result=f.GetAnswer();
            Assert.AreEqual(list[num], result.ToString());
        }
Esempio n. 5
0
 public InvokableCandidateFJTask(IRunnable r, FJTaskRunnerGroup group)
 {
     this.r = r;
     this.group = group;
 }
Esempio n. 6
0
 /// <summary>
 /// Creates a new <see cref="InvokableFJTask"/> instance.
 /// </summary>
 internal InvokableFJTask(IRunnable r, FJTaskRunnerGroup group)
 {
     wrapped = r;
     this.group = group;
 }
Esempio n. 7
0
 /// <summary>
 /// Create a new <see cref="FJTaskRunner"/>, setting its thread
 /// as needed
 /// </summary>
 public static FJTaskRunner New(FJTaskRunnerGroup runnerGroup)
 {
     FJTaskRunner runner = new FJTaskRunner(runnerGroup);
     Thread t = new Thread(new ThreadStart(runner.DoStart));
     t.Name = "FJTaskRunner thread #" + t.GetHashCode();
     runner.SetThread(t);
     return runner;
 }
Esempio n. 8
0
 /// <summary>  
 /// Constructor called only during FJTaskRunnerGroup initialization
 /// </summary>		
 protected internal FJTaskRunner(FJTaskRunnerGroup g)
 {
     deq = VolatileTaskRef.NewArray(INITIAL_CAPACITY);
     barrier = new Object();
     scanPriority_ = FJTaskRunnerGroup.DefaultScanPriority;
     group_ = g;
     victimRNG = new Random(this.GetHashCode());
 }
Esempio n. 9
0
 /// <summary> Execute this task. This method merely places the task in a
 /// group-wide scheduling queue.
 /// It will be run
 /// the next time any TaskRunner thread is otherwise idle.
 /// This scheduling  maintains FIFO ordering of started tasks
 /// with respect to
 /// the group of worker threads.
 /// </summary>
 public virtual void  Start()
 {
     FJTaskRunnerGroup.ExecuteTask(this);
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a new <see cref="InvokableFJTask"/> instance.
 /// </summary>
 internal InvokableFJTask(IRunnable r, FJTaskRunnerGroup group)
 {
     wrapped    = r;
     this.group = group;
 }
Esempio n. 11
0
 public InvokableCandidateFJTask(IRunnable r, FJTaskRunnerGroup group)
 {
     this.r     = r;
     this.group = group;
 }