Esempio n. 1
0
 static void Main(string[] args)
 {
     IRndGenerator <int> rndActor =
         ActorWrapper.WrapActor(RndGeneratorFactory.NewSimpleRndGenerator());
     Task <int> nextTask = rndActor.GetNextNumber();
     // int number = await nextTask;
 }
Esempio n. 2
0
        public static void _Main()
        {
            ICounter pinger = ActorWrapper.WrapActor <ICounter>(() => new CounterActor());

            pinger.SetSelf(pinger);
            pinger.Start();
            Thread.Sleep(1000);
        }
        public void TestDelegateUsesRightLock()
        {
            var directActor   = ActorWrapper.WrapActor <IDirectActor>(() => new DirectActor());
            var indirectActor = ActorWrapper.WrapActor <IIndirectActor>(() => new IndirectActor());
            var runningActor  = ActorWrapper.WrapActor <IRunningActor>(() => new RunningActor());

            directActor.InitialMethod(runningActor, indirectActor);
            Thread.Sleep(300);
        }
        public void MethodsRunInOrder()
        {
            ActingCompleteWaiter.Reset();

            var setAndCheckActor = ActorWrapper.WrapActor <ISetAndCheckActor>(() => new SetAndCheckActor());

            for (int i = 0; i < c_Trials; i++)
            {
                setAndCheckActor.SetValue(i);
                setAndCheckActor.CheckValue(i);
            }

            ActingCompleteWaiter.WaitForActionsToComplete(1000);
        }
Esempio n. 5
0
        public void TimeCountingUp()
        {
            ActingCompleteWaiter.Reset();

            var firstActor  = ActorWrapper.WrapActor <ICallAroundActor>(() => new CallAroundActor());
            var secondActor = ActorWrapper.WrapActor <ICallAroundActor>(() => new CallAroundActor());
            var thirdActor  = ActorWrapper.WrapActor <ICallAroundActor>(() => new CallAroundActor());

            firstActor.SetNextActor(secondActor);
            secondActor.SetNextActor(thirdActor);
            thirdActor.SetNextActor(firstActor);

            firstActor.CountUp(0, m_Total);

            ActingCompleteWaiter.WaitForActionsToComplete(1000);
        }
Esempio n. 6
0
        public void DoIt()
        {
            IDictionaryActor <string, int> d =
                ActorWrapper.WrapActor <IDictionaryActor <string, int> >(() => new DictionaryActor <string, int>());

            int r = 3;

            d["hello"] = 3;

            d.Atomically(
                dictionary =>
            {
                dictionary["hello"] = dictionary["hello"] + r;
                return(true);
            });
        }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            IPonger ponger = ActorWrapper.WrapActor <IPonger>(() => new Ponger());
            IPinger pinger = ActorWrapper.WrapActor <IPinger>(() => new Pinger(ponger));

            //IPonger ponger = new Ponger();
            //IPinger pinger = new Pinger(ponger);

            new Thread(delegate(object o)
            {
                Thread.Sleep(10000);

                Console.WriteLine(s_Count);
                Thread.Sleep(1000);
            }).Start();

            pinger.Ping();
        }