Exemplo n.º 1
0
 public CollisionMesh(CollisionMesh mesh)
 {
     RenderScene = mesh.RenderScene;
     Resource    = mesh.Resource;
     Resource.Acquire();
     Resource.AddResourceEventListener(this);
     WindCW = mesh.WindCW;
 }
Exemplo n.º 2
0
    private IEnumerator <Task> PreSchooler(Process process, object data)
    {
        int      id            = _idPool++;
        IUniform rnd           = UniformStreams.DefaultStreams[0];
        long     delayDuration = (long)(rnd.NextDouble() * 100.0);

        Console.WriteLine(id + ": Attempting to get a thwacker @ " + Now);
        yield return(_thwacker.Acquire(process));                        // (1)

        Console.WriteLine(id + ": Got the a thwacker @ " + Now);
        yield return(process.Delay(delayDuration));

        Console.WriteLine(id + ": Releasing the thwacker @ " + Now);
        yield return(_thwacker.Release(process));                        // (2)

        Console.WriteLine(id + ": PreSchooler process ends @ " + Now);
        yield break;
    }
Exemplo n.º 3
0
        protected override IEnumerator <Task> GetProcessSteps()
        {
            Resource barbers = (Resource)ActivationData;

            yield return(barbers.Acquire(this));

            System.Diagnostics.Debug.Assert(barbers == Activator);
            System.Diagnostics.Debug.Assert(ActivationData != null);
            Barber barber = (Barber)ActivationData;

            WaitOnTask(barber);
            yield return(Suspend());

            // HINT: The above two lines of code can be shortened to
            //          yield return barber;

            Console.WriteLine("Customer pays {0} for the haircut.",
                              barber.Name);

            yield return(barbers.Release(this));
        }
Exemplo n.º 4
0
        protected override IEnumerator<Task> GetProcessSteps()
        {
            Resource barbers = (Resource)ActivationData;
            //NewResource barbers = (NewResource)ActivationData;
            Console.WriteLine("M         so Cus trong hang doi = " + barbers.BlockCount + " " + Now);
            //if (barbers.BlockCount < QueueCapacity)//max so Cus trong hang doi
            //{

            //    yield return barbers.Acquire(this);//?o?n n?y s? nh?y sang Barber ?? th?c hi?n, khi th?c hi?n xong s? nh?y v? 2//Sau doan nay Cus se luu vao hang doi
            //}
            //else
            //{
            //    yield break;
            //}

            if (barbers.BlockCount < Condition)//max so Cus trong hang doi
            {
                yield break;

            }
            else
            {               
                yield return barbers.Acquire(this);//?o?n n?y s? nh?y sang Barber ?? th?c hi?n, khi th?c hi?n xong s? nh?y v? 2//Sau doan nay Cus se luu vao hang doi
            }


            System.Diagnostics.Debug.Assert(barbers == Activator);
            System.Diagnostics.Debug.Assert(ActivationData != null);
            Barber barber = (Barber)ActivationData;
            Points.Add(new Point(Now, barber.BlockCount));
            Console.WriteLine("H  H      so Cus trong hang doi = " + barbers.BlockCount + " " + Now);

            TimeIn = this.Now;
            Console.WriteLine(this.Now + " ? " + barber.Name + " begins cutting hair of customer " + this.Name);

            WaitOnTask(barber);
            yield return Suspend();
            // HINT: The above two lines of code can be shortened to
            //          yield return barber;

            Console.WriteLine("NN  NN    so Cus trong hang doi = " + barbers.BlockCount + " " + Now);

            TimeOut = this.Now;
            Console.WriteLine(this.Now + " x Customer " + Name + " pays {0} for the haircut.",
                barber.Name);
            Console.WriteLine($"thoi gian trong hang doi {TimeIn - this.TimeCome}" +
                              $" --- thoi gian trong he thong {TimeOut - this.TimeCome}");

            yield return barbers.Release(this);//giai phong bo nho

            //Resource barbers = (Resource)ActivationData;
            //yield return barbers.Acquire(this);

            //System.Diagnostics.Debug.Assert(barbers == Activator);
            //System.Diagnostics.Debug.Assert(ActivationData != null);
            //Barber barber = (Barber)ActivationData;

            //WaitOnTask(barber);
            //yield return Suspend();
            //// HINT: The above two lines of code can be shortened to
            ////          yield return barber;

            //Console.WriteLine("Customer pays {0} for the haircut.",
            //    barber.Name);

            //yield return barbers.Release(this);
        }