internal void SynchronousPrepareBatches(Frame frame) { var context = new Batch.PrepareContext(PrepareManager, false, frame.BatchesToRelease); context.PrepareMany(frame.Batches); PrepareManager.AssertEmpty(); }
internal void ParallelPrepareBatches(Frame frame) { var context = new Batch.PrepareContext(PrepareManager, true, frame.BatchesToRelease); context.PrepareMany(frame.Batches); PrepareManager.Wait(); PrepareManager.AssertEmpty(); }
internal void SynchronousPrepareBatches(Frame frame) { var context = new Batch.PrepareContext(PrepareManager, false); context.PrepareMany(ref frame.Batches); ThreadGroup.NotifyQueuesChanged(); PrepareManager.AssertEmpty(); frame.BatchesToRelease.AddRange(in context.BatchesToRelease); }
internal static void Execute(Batch batch, ref Batch.PrepareContext context) { var isCombined = false; batch.GetState(out bool temp, out isCombined, out bool temp2, out bool temp3, out bool temp4); if (!isCombined) { batch.Prepare(context); } batch.SetPrepareQueued(false); }
public void PrepareMany <T> (DenseList <T> batches, Batch.PrepareContext context) where T : IBatch { int totalAdded = 0; const int blockSize = 128; using (var buffer = BufferPool <Task> .Allocate(blockSize)) { var task = new Task(null, context); int j = 0, c = batches.Count; T batch; for (int i = 0; i < c; i++) { batches.GetItem(i, out batch); if (batch == null) { continue; } ValidateBatch(batch, true); task.Batch = batch; if (context.Async) { buffer.Data[j++] = task; totalAdded += 1; if (j == (blockSize - 1)) { Queue.EnqueueMany(new ArraySegment <Task>(buffer.Data, 0, j)); j = 0; } } else { task.Execute(); } } if (context.Async && (j > 0)) { Queue.EnqueueMany(new ArraySegment <Task>(buffer.Data, 0, j)); } } if (context.Async) { Group.NotifyQueuesChanged(); } }
public void Prepare(IBatch batch, Batch.PrepareContext context) { if (batch == null) { return; } ValidateBatch(batch, true); var task = new Task(batch, context); if (context.Async) { Queue.Enqueue(task); // FIXME: Is this too often? Group.NotifyQueuesChanged(); } else { task.Execute(); } }
public void Prepare(Batch batch, ref Batch.PrepareContext context) { if (batch == null) { return; } ValidateBatch(batch, true); if (batch is IBatchContainer container) { container.PrepareChildren(ref context); } var task = new Task(batch, ref context); if (context.Async) { Queue.Enqueue(task, false); } else { task.Execute(); } }
public void PrepareMany(ref DenseList <Batch> batches, ref Batch.PrepareContext context) { if (batches.Count < 2) { if (batches.Count == 1) { Prepare(batches[0], ref context); } return; } var task = default(Task); task.Context = context; foreach (var b in batches) { ValidateBatch(b, true); if (b is IBatchContainer container) { container.PrepareChildren(ref context); } task.Batch = b; if (context.Async) { Queue.Enqueue(ref task, false); } else { task.Execute(); } task = new Task(b, ref context); } }
public Task(Batch batch, ref Batch.PrepareContext context) { Batch = batch; Context = context; }
void IBatchContainer.PrepareChildren(ref Batch.PrepareContext context) { throw new InvalidOperationException("This should never be invoked on a Frame"); }