Exemplo n.º 1
0
        private async Task <IReentrantSelfManagedGrain[]> InitACGrains_Reentrant(int offset, int num)
        {
            var         fanOutGrains = new IReentrantSelfManagedGrain[num];
            List <Task> promises     = new List <Task>();

            logger.Info("Creating {0} fan-out {1} worker grains with offset={2}", num, "reentrant", offset);
            for (int i = 0; i < num; i++)
            {
                int idx   = offset + i;
                var grain = GrainFactory.GetGrain <IReentrantSelfManagedGrain>(idx);
                fanOutGrains[i] = grain;
                int  next    = offset + ((i + 1) % num);
                Task promise = grain.SetDestination(next);
                promises.Add(promise);
            }
            await Task.WhenAll(promises);

            return(fanOutGrains);
        }
Exemplo n.º 2
0
        public Task Ping(int seconds)
        {
            logger.Info("Start Ping({0})", seconds);
            var start = DateTime.UtcNow;
            var end   = start + TimeSpan.FromSeconds(seconds);
            int foo   = 0;

            while (DateTime.UtcNow < end)
            {
                foo++;
                if (foo > 100000)
                {
                    foo = 0;
                }
            }

            logger.Info("Before GetCounter - OtherId={0}", destination);
            IReentrantSelfManagedGrain otherGrain = GrainFactory.GetGrain <IReentrantSelfManagedGrain>(destination);
            var ctr = otherGrain.GetCounter();

            logger.Info("After GetCounter() - returning promise");
            return(ctr);
        }
Exemplo n.º 3
0
 private async Task<IReentrantSelfManagedGrain[]> InitACGrains_Reentrant(int offset, int num)
 {
     var fanOutGrains = new IReentrantSelfManagedGrain[num];
     List<Task> promises = new List<Task>();
     logger.Info("Creating {0} fan-out {1} worker grains with offset={2}", num, "reentrant", offset);
     for (int i = 0; i < num; i++)
     {
         int idx = offset + i;
         var grain = GrainFactory.GetGrain<IReentrantSelfManagedGrain>(idx);
         fanOutGrains[i] = grain;
         int next = offset + ((i + 1) % num);
         Task promise = grain.SetDestination(next);
         promises.Add(promise);
     }
     await Task.WhenAll(promises);
     return fanOutGrains;
 }