private void InitBuffers() { _predictionBuffer = new RigidbodyState[_trajectorySegments]; _historyBuffer = new CircularBuffer <RigidbodyState>(60); ClearBuffers(); }
private void Awake() { const float bufferLenghtInS = 5f; _simulation = GetComponent <PlayerSimulation>(); _inputHistory = new CircularBuffer <PlayerInput>(Mathf.RoundToInt(60 * bufferLenghtInS)); _serverHistory = new CircularBuffer <RigidbodyState>(50); // Todo: in external debug vizualizer component }
public BlockConsumerContainer(int blockCount, int blockSize) { availableBlockConsumers = new Dictionary<string, IBlockConsumer>(); items = new List<IBlockConsumer>(); blockSource = new ByteStreamToBlock(blockSize); circb = new CircularBuffer<byte[]>((int)Math.Log(blockCount, 2)); b = new RefillBuffer<byte[]>(circb, blockSource); }
public BlockConsumerContainer(int blockCount, int blockSize) { availableBlockConsumers = new Dictionary <string, IBlockConsumer>(); items = new List <IBlockConsumer>(); blockSource = new ByteStreamToBlock(blockSize); circb = new CircularBuffer <byte[]>((int)Math.Log(blockCount, 2)); b = new RefillBuffer <byte[]>(circb, blockSource); }
public RefillBuffer(ICircularBuffer <T> circBuffer, IBlockSource <T> blockSource) { this.circBuffer = circBuffer; this.blockSource = blockSource; for (int i = 0; i < circBuffer.Buffer.Length; i++) { blockSource.InitializeBlock(out circBuffer.Buffer[i]); } }
public override Property Post(ICircularBuffer <T> _arg2, CModel <T> _arg3) { var cbTail = _arg2.ToArray().Last(); var modelTail = _arg3.Items.Last(); return (cbTail.Equals(modelTail) .ToProperty() .Label($"After enqueue expected Actual.Last()[{cbTail}] == Model.Last()[{modelTail}]")); }
public static byte[] Slice(this ICircularBuffer <byte> array, int index, int length) { if (array == null) { throw new ArgumentNullException("array"); } if (index + length > array.Size) { throw new ArgumentOutOfRangeException("length", string.Format("index: ({0}), length({1}) index + length cannot be longer than Array.length({2})", index, length, array.Size)); } var result = new byte[length]; array.DirectBufferRead(index, result, 0, length); return(result); }
/// <summary> /// Helper method to test the properties Count, IsEmpty and IsFull of a circular buffer. /// </summary> /// <typeparam name="T">Base type of the circular buffer</typeparam> /// <param name="buffer">Circular buffer to test</param> /// <param name="count">Expected number of items</param> static void TestProperties <T>(ICircularBuffer <T> buffer, uint count) { if (buffer.Count != count) { throw new Exception(String.Format("buffer.Count {0} != {1}", buffer.Count, count)); } if (buffer.IsEmpty != (count == 0)) { throw new Exception(String.Format("buffer.IsEmpty {0} != {1}", buffer.IsEmpty, count == 0)); } if (buffer.IsFull != (count >= buffer.Capacity)) { throw new Exception(String.Format("buffer.IsFull {0} != {1}", buffer.IsFull, count >= buffer.Capacity)); } }
private void AllocateBuffers() { int verticesNum = kernel.pointsNum * RealPointsPerRing; vertices = new CircularBuffer <Vector3>(verticesNum); normals = new CircularBuffer <Vector3>(verticesNum); uvs = new CircularBuffer <Vector2>(verticesNum); int trianglesNum = (kernel.pointsNum - 1) * trianglesPerSegment; triangles = new CircularBuffer <int>(trianglesNum * 3); Mesh mesh = GetComponent <MeshFilter>().mesh; mesh.MarkDynamic(); }
public QueueAdapter([NotNull] TQueue tQueue) { _adapter = tQueue switch { IDeque <T> deque => new DequeProxy(deque), ICircularBuffer <T> buffer => new CircularBufferProxy(buffer), IHeap <T> heap => new HeapProxy(heap), Queue <T> queue => new QueueProxy(queue), IQueue <T> queue => new QueueProxy(queue), Stack <T> stack => new StackProxy(stack), IStack <T> stack => new StackProxy(stack), ConcurrentQueue <T> queue => new ConcurrentQueueProxy(queue), ConcurrentStack <T> stack => new ConcurrentStackProxy(stack), BlockingCollection <T> blockingCollection => new BlockingCollectionProxy(blockingCollection), LinkedList <T> linkedList => new LinkedListProxy(linkedList), List <T> list => new ListProxy(list), _ => throw new NotSupportedException() }; Queue = tQueue; }
private void AddSegmentTriangles() { ICircularBuffer <ValueTransform> path = kernel.Path; if (path.Count >= 2) { int ring1Offset = path.RawPosition(path.Count - 2) * RealPointsPerRing; int ring2Offset = path.RawPosition(path.Count - 1) * RealPointsPerRing; int[] quadIndices = new int[4]; int[] triangleIndices = new int[6]; for (int i = 0; i < visiblePointsPerRing; ++i) { quadIndices[0] = ring1Offset + i; quadIndices[1] = ring1Offset + i + 1; quadIndices[2] = ring2Offset + i + 1; quadIndices[3] = ring2Offset + i; MeshUtils.ConvertQuadToTriangles(quadIndices, triangleIndices); triangles.Enqueue(triangleIndices); } } }
public override Property Post(ICircularBuffer <T> _arg2, CModel <T> _arg3) { return ((_arg2.Count == _arg3.Items.Count).ToProperty() .Label($"Expected {_arg3.Items.Count}, got {_arg2.Count}")); }
public override ICircularBuffer <T> RunActual(ICircularBuffer <T> obj0) { obj0.Clear(); return(obj0); }
public override ICircularBuffer <T> RunActual(ICircularBuffer <T> obj0) { return(obj0); }
public override Property Post(ICircularBuffer <T> _arg2, CModel <T> _arg3) { return(_arg2.Skip(1).SequenceEqual(_arg3.Items.Skip(1)).ToProperty()); }
public override ICircularBuffer <T> RunActual(ICircularBuffer <T> obj0) { dequeValue = obj0.Dequeue(); return(obj0); }
/// <summary> /// Copy constructor /// </summary> internal protected CircularByteBuf(IByteBufAllocator allocator, ICircularBuffer <byte> buffer) : base(buffer.MaxCapacity) { InternalBuffer = buffer; Alloc = allocator; }
//public int BufferUnderrunCount { get; private set; } public RefillBuffer(ICircularBuffer <T> circBuffer, IBlockSource <T> blockSource, int consumerCount) : this(circBuffer, blockSource) { Initialize(consumerCount); }
public CachingDictionary(PersistantDictionary <TKey, TValue> persistantDictionary, int maxCacheCount) { _persistantDictionary = persistantDictionary; _localDictionary = new Dictionary <TKey, TValue>(maxCacheCount); _localKeyQueue = new CircularBuffer <TKey>(maxCacheCount); }
/// <summary> /// Copy constructor /// </summary> internal protected CircularByteBuf(IByteBufAllocator allocator, ICircularBuffer<byte> buffer) : base(buffer.MaxCapacity) { InternalBuffer = buffer; Alloc = allocator; }
public LocalCache(int capacity) { _localDictionary = new Dictionary <TKey, TValue>(capacity); _localKeyQueue = new CircularBuffer <TKey>(capacity); }
public override ICircularBuffer <T> RunActual(ICircularBuffer <T> obj0) { obj0 = _factory(_listSize.Value); return(obj0); }
public override ICircularBuffer <T> RunActual(ICircularBuffer <T> obj0) { obj0.Enqueue(_data.Value); return(obj0); }
/// <summary> /// The default buffer is 1<<16, if small will automatically add buffer block /// </summary> /// <param name="bufferSize"></param> public TcpSocket(int bufferSize = 1 << 16) { SendBuffer = new CircularBuffer <byte>(bufferSize); ReceiveBuffer = new CircularBuffer <byte>(bufferSize); }
public CircularBufferProxy(ICircularBuffer <T> buffer) { _buffer = buffer; }