Ejemplo n.º 1
0
 private void Awake()
 {
     if (_Instance != null)
     {
         Debug.LogError("Batching can have only one instance");
         enabled = false;
         return;
     }
     _Instance   = this;
     reqToUpdate = 0;
 }
Ejemplo n.º 2
0
 void UnBatch()
 {
     if (!Application.isPlaying)
     {
         return;
     }
     if (wasBatched)
     {
         wasBatched  = false;
         ren.enabled = true;
         Batching.Remove(transform, ren.sharedMaterial);
     }
 }
Ejemplo n.º 3
0
 void Batch()
 {
     if (!Application.isPlaying)
     {
         return;
     }
     if (useBatching)
     {
         Batching.Add(transform, dynamicMesh, ren.sharedMaterial);
         ren.enabled = false;
         wasBatched  = true;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create an action batched up in a specific manner
        /// </summary>
        /// <param name="batching"></param>
        /// <param name="vdis"></param>
        /// <param name="sr"></param>
        /// <returns></returns>
        public ParallelAction BatchAs(Batching batching, List <VDI> vdis, SR sr)
        {
            if (batching == Batching.VdiMigrate)
            {
                CreatedActionTitle = String.Format(Messages.ACTION_MIGRATING_X_VDIS, Convert.ToString(vdis.Count), sr.name_label);
                return(CreateNewParallelAction(BatchAsVdiMigrate(vdis, sr)));
            }

            if (batching == Batching.VdiMove)
            {
                CreatedActionTitle = String.Format(Messages.ACTION_MOVING_X_VDIS, Convert.ToString(vdis.Count), sr.name_label);
                return(CreateNewParallelAction(BatchAsVdiMove(vdis, sr)));
            }

            throw new NotSupportedException("The provided option was not supported");
        }
Ejemplo n.º 5
0
        public static async Task WordCountOrchestrator(
            [OrchestrationTrigger] IDurableOrchestrationContext ctx,
            ILogger log
            )
        {
            var input = ctx.GetInput <WordCountInput>();

            log.LogInformation($"Word Count Orchestrator started with {input.Name}.");

            var batches = Batching.ToBatches(ToLines(input.Content));

            var mapResults = await Task.WhenAll(
                batches.Select(
                    batch => ctx.CallActivityAsync <IList <Result <string, int> > >(
                        functionName: nameof(WordCountMap),
                        input: batch
                        )
                    )
                );

            log.LogInformation("After mapping");

            var groups = await ctx.CallActivityAsync <IList <Group <string, int> > >(
                functionName : nameof(WordCountGroup),
                input : mapResults
                );

            log.LogInformation("After grouping");

            var reduceResults = await Task.WhenAll(
                groups.Select(
                    group => ctx.CallActivityAsync <Result <string, int> >(
                        functionName: nameof(WordCountReduce),
                        input: group
                        )
                    )
                );

            log.LogInformation("After reducing");

            await ctx.CallActivityAsync <string>(
                functionName : nameof(WordCountOutput),
                input : reduceResults
                );

            log.LogInformation("After outputting");
        }
Ejemplo n.º 6
0
        public static ITargetBlock <T> Create <T>(
            Func <IReadOnlyList <T>, Task> action, int maxBatchSize, Batching batching, DataflowBlockOptions options)
        {
            Contracts.Requires.That(action != null);
            Contracts.Requires.That(options != null);

            switch (batching)
            {
            case Batching.Dynamic:
                options = options.CreateCopy();
                options.BoundedCapacity = maxBatchSize;
                return(new DynamicBatchActionBlock <T>(action, options));

            case Batching.Static:
                return(new StaticBatchActionBlock <T>(action, maxBatchSize, options));

            default: throw InvalidEnumArgument.CreateException(nameof(batching), batching);
            }
        }
        public override string ToString()
        {
            switch (m_specialTag)
            {
            case TemplateSpecialTags.RenderType:
                return(TagName + IOUtils.VALUE_SEPARATOR +
                       (RenderType != RenderType.Custom? RenderType.ToString(): TagValue) + IOUtils.VALUE_SEPARATOR +
                       m_specialTag);

            case TemplateSpecialTags.Queue:
                return(TagName + IOUtils.VALUE_SEPARATOR +
                       m_renderQueue.ToString() + IOUtils.VALUE_SEPARATOR +
                       m_specialTag + IOUtils.VALUE_SEPARATOR +
                       m_renderQueueOffset);

            case TemplateSpecialTags.DisableBatching:
                return(TagName + IOUtils.VALUE_SEPARATOR +
                       Batching.ToString() + IOUtils.VALUE_SEPARATOR +
                       m_specialTag);
            }

            return(TagName + IOUtils.VALUE_SEPARATOR + TagValue);
        }
        /// <summary>
        /// Create an action batched up in a specific manner
        /// </summary>
        /// <param name="batching"></param>
        /// <param name="vdis"></param>
        /// <param name="sr"></param>
        /// <returns></returns>
        public ParallelAction BatchAs(Batching batching, List<VDI> vdis, SR sr)
        {
            if (batching == Batching.VdiMigrate)
            {
                CreatedActionTitle = String.Format(Messages.ACTION_MIGRATING_X_VDIS, Convert.ToString(vdis.Count), sr.name_label);
                return CreateNewParallelAction(BatchAsVdiMigrate(vdis, sr));
            }

            if (batching == Batching.VdiMove)
            {
                CreatedActionTitle = String.Format(Messages.ACTION_MOVING_X_VDIS, Convert.ToString(vdis.Count), sr.name_label);
                return CreateNewParallelAction(BatchAsVdiMove(vdis, sr));
            }

            throw new NotSupportedException("The provided option was not supported");
        }
Ejemplo n.º 9
0
 public static ITargetBlock <T> Create <T>(
     Func <IReadOnlyList <T>, Task> action, int maxBatchSize, Batching batching) =>
 Create(action, maxBatchSize, batching, new DataflowBlockOptions());