public ArchivingEngine(
     string sourceRootFolder,
     string targetRootFolder,
     ArchivingSettings settings,
     TotalStatistics statistics,
     ILog log)
 {
     this.sourceRootFolder = sourceRootFolder;
     this.targetRootFolder = targetRootFolder;
     this.statistics = statistics;
     this.settings = settings;
     this.log = log;
     queue = new RingBuffer<Processing>();
     processingDistributor = new ProcessingDistributor(
         sourceRootFolder,
         targetRootFolder,
         statistics,
         queue,
         log);
     processingPool = new PipelinesPool(processingDistributor);
     retrievingDistributor = new RetrievingDistributor(
         queue,
         log);
     retrievingPool = new PipelinesPool(retrievingDistributor);
 }
 public void setUp()
 {
     ringBuffer = new RingBuffer<StubEntry>(new StubFactory(), 20, new SingleThreadedStrategy(),
                                            new BusySpinStrategy<StubEntry>());
     consumerBarrier = ringBuffer.CreateConsumerBarrier();
     producerBarrier = ringBuffer.CreateProducerBarrier(new NoOpConsumer(ringBuffer));
 }
        public void PerfTestThreadsWithDequeues()
        {
            RingBuffer<string> ringBuffer = new RingBuffer<string>(1000);

            Stopwatch ringWatch = new Stopwatch();
            List<Task> ringTasks = new List<Task>();
            for (int t = 0; t < 10; t++)
            {
                ringTasks.Add(new Task(() =>
                {
                    for (int i = 0; i < 1000000; i++)
                    {
                        ringBuffer.Enqueue("StringOfFun");
                    }
                }));

            }
            for (int t = 0; t < 10; t++)
            {
                ringTasks.Add(new Task(() =>
                {
                    for (int i = 0; i < 1000000; i++)
                    {
                        string foo;
                        ringBuffer.TryDequeue(out foo);
                    }
                }));
            }
            ringWatch.Start();
            ringTasks.ForEach(t => t.Start());
            Task.WaitAny(ringTasks.ToArray());
            ringWatch.Stop();

            Assert.That(ringWatch.ElapsedMilliseconds, Is.LessThan(800));
        }
 public OneToOneSequencedPollerThroughputTest()
 {
     _ringBuffer = RingBuffer<ValueEvent>.CreateSingleProducer(ValueEvent.EventFactory, _bufferSize, new YieldingWaitStrategy());
     _poller = _ringBuffer.NewPoller();
     _ringBuffer.AddGatingSequences(_poller.Sequence);
     _pollRunnable = new PollRunnable(_poller);
 }
		public XInputDeviceManager()
		{
			if (InputManager.XInputUpdateRate == 0)
			{
				timeStep = Mathf.FloorToInt( Time.fixedDeltaTime * 1000.0f );
			}
			else
			{
				timeStep = Mathf.FloorToInt( 1.0f / InputManager.XInputUpdateRate * 1000.0f );
			}

			bufferSize = (int) Math.Max( InputManager.XInputBufferSize, 1 );

			for (int deviceIndex = 0; deviceIndex < maxDevices; deviceIndex++)
			{
				gamePadState[deviceIndex] = new RingBuffer<GamePadState>( bufferSize );
			}

			StartWorker();

			for (int deviceIndex = 0; deviceIndex < maxDevices; deviceIndex++)
			{
				devices.Add( new XInputDevice( deviceIndex, this ) );
			}

			Update( 0, 0.0f );
		}
 public void Initialize(RingBuffer<InboundMessageProcessingEntry> ringBuffer)
 {
     _ringBuffer = ringBuffer;
     _ipEndPoint = _endpoint.EndPoint;
     _receiver.RegisterCallback(_ipEndPoint, DoReceive);
     _receiver.ListenToEndpoint(_ipEndPoint);
 }
 public override void ActivateOptions()
 {
     base.ActivateOptions();
     pendingAppends = new RingBuffer<LoggingEvent>(QueueSizeLimit);
     pendingAppends.BufferOverflow += OnBufferOverflow;
     StartAppendTask();
 }
    public void AddItemsToBufferOfSetSize_RemovesItemsFirstAddedToBufferToFitInMoreItems()
    {
      var buffer = new RingBuffer<string>(2);
      buffer.Add("1");
      buffer.Add("2");

      List<string> items = buffer.ToList();
      Assert.AreEqual("1", items[0]);
      Assert.AreEqual("2", items[1]);

      buffer.Add("3");
      items = buffer.ToList();
      Assert.AreEqual("2", items[0]);
      Assert.AreEqual("3", items[1]);

      buffer.Add("4");
      items = buffer.ToList();
      Assert.AreEqual("3", items[0]);
      Assert.AreEqual("4", items[1]);

      buffer.Add("5");
      items = buffer.ToList();
      Assert.AreEqual("4", items[0]);
      Assert.AreEqual("5", items[1]);
    }
    /// <summary>
    /// Returns the product of the stdev of the x and y components of the previous n mouse states,
    /// which makes for a very good input trigger. There are many optimizations available for this function.
    /// 
    /// The stdev strategy parameters must be based upon the physical problem of detecting clicks via a
    /// concentration of points within a region. This means that the Hz rate of the sensor is an input,
    /// as well as other physical characteristics of the device and its current calibration.
    /// 
    /// There need be no weighting in this function either; since we assume the user is focused on a given point, all
    /// points captured within a sample of time window t are estimates of the true 'hidden' value of the current points.
    /// </summary>
    /// <param name="numPoints">The number of previous points to include in the stdev-xy product.</param>
    /// <returns></returns>
    public double StDevXyProduct(int numPoints, RingBuffer<EyeDatum> sensorData)
    {
      int i;
      double mu_x = 0.0, mu_y = 0.0;
      double var_x = 0.0, var_y = 0.0;

      //get the means
      for (i = 0; i < numPoints && i < sensorData.Count; i++)
      {
        mu_x += sensorData[i].MouseData.X;
        mu_y += sensorData[i].MouseData.Y;
      }
      mu_x /= (double)i;
      mu_y /= (double)i;
      
      //get the variance of the x and y coordinates in this set
      for (i = 0; i < numPoints && i < sensorData.Count; i++)
      {
        var_x += ((sensorData[i].MouseData.X - mu_x) * (sensorData[i].MouseData.X - mu_x));
        var_y += ((sensorData[i].MouseData.Y - mu_y) * (sensorData[i].MouseData.Y - mu_y));
      }

      //optimization TODO: there is no need for expensive square-root for the trigger we're looking for;
      //by laws of exponents, (x^0.5)(y^0.5) == (x*y)^0.5, and thus the sqrt is actually unnecessary for
      //a trigger, since the trigger baseline can simply be squared. And also if we're careful wrt overflow.
      return Math.Sqrt(var_x) * Math.Sqrt(var_y);
    }
Beispiel #10
0
    public EyeDevice(int sensorHz)
    {
      _exit = false;
      _pendingDatum = false;
      //the data history should exceed the Hz of sensors on the market; this gives 2 seconds history for a 250Hz sensor.
      //A larger value could be used for historical or other vector analysis on the extended inputs.
      SENSOR_DATA_HISTORY = 500;
      _eyeDataBuffer = new RingBuffer<EyeDatum>(SENSOR_DATA_HISTORY);
      _filter = new EyeSensorFilter();
      _newDatumLock = new Object();

      //the number of pending datum misses by the consumer thread
      _misses = 0;

      if (sensorHz >= 500)
      {
        Console.WriteLine("ERROR sensorHz="+sensorHz+" is to high sensitivity for sensor poll. Large (>500Hz) sensorHz values");
        Console.WriteLine("may prevent sensor data from being read. Re-evaluate algorithms in EyeDevice.");
      }

      //_currentState must have some initial value, or readers will get null ref
      _currentState = Mouse.GetState();

      //Set the poll scan time. Note this math is intentionally incorrect: using 1200 instead of 1000 is intended so that the
      //sensor-polling thread always runs slightly faster than the rate at which manufacturers claim for their tracker Hz.
      _sensorScanTime_ms = 1200 / sensorHz;
      _computationScanTime_ms = _sensorScanTime_ms;
      //launch the sensor polling thread.
      _pollingThread = new Thread(new ThreadStart(_pollSensor));
      _pollingThread.Start();

      //kick the computation thread
      _computationThread = new Thread(new ThreadStart(_runComputations));
      _computationThread.Start();
    }
 public void ClearTest_notempty()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(7);
     Assert.IsFalse(rb.IsEmpty);
     rb.Clear();
     Assert.IsTrue(rb.IsEmpty);
 }
 public void Initialize(RingBuffer<InboundMessageProcessingEntry> ringBuffer)
 {
     _ringBuffer = ringBuffer;
     foreach (IWireReceiverTransport wireReceiverTransport in _transports)
     {
         wireReceiverTransport.Initialize(ringBuffer);
     }
 }
 public void RetrievedInCorrectOrder() {
     RingBuffer<int> _buffer = new RingBuffer<int>(iterations);
     populateBuffer(iterations, _buffer);
     for(int i = 0; i < iterations; i++) {
         int _tmp = _buffer.Get();
         Assert.AreEqual(i, _tmp, "Incorrect Sequence");
     }
 }
        public void SetUp()
        {
            _sequencerMock = new Mock<ISequencer>();
            _sequencer = _sequencerMock.Object;

            _sequencerMock.SetupGet(x => x.BufferSize).Returns(16);
            _ringBuffer = new RingBuffer<StubEvent>(StubEvent.EventFactory, _sequencer);
        }
 public ValuePublisher(Barrier cyclicBarrier
 , RingBuffer<ValueEvent> ringBuffer
 , long iterations)
 {
     this.cyclicBarrier = cyclicBarrier;
     this.ringBuffer = ringBuffer;
     this.iterations = iterations;
 }
Beispiel #16
0
 public TestWaiter(Barrier barrier, ISequenceBarrier sequenceBarrier, RingBuffer<StubEvent> ringBuffer, long initialSequence, long toWaitForSequence)
 {
     _barrier = barrier;
     _sequenceBarrier = sequenceBarrier;
     _ringBuffer = ringBuffer;
     _initialSequence = initialSequence;
     _toWaitForSequence = toWaitForSequence;
 }
 public OneToOneSequencedBatchThroughputTest()
 {
     _ringBuffer = RingBuffer<ValueEvent>.CreateSingleProducer(ValueEvent.EventFactory, _bufferSize, new YieldingWaitStrategy());
     var sequenceBarrier = _ringBuffer.NewBarrier();
     _handler = new ValueAdditionEventHandler();
     _batchEventProcessor = new BatchEventProcessor<ValueEvent>(_ringBuffer, sequenceBarrier, _handler);
     _ringBuffer.AddGatingSequences(_batchEventProcessor.Sequence);
 }
 public void PutIncrementsSize() {
     RingBuffer<int> _buffer = new RingBuffer<int>(iterations);
     for(int i = 0; i < iterations; i++) {
         int _tmp = i;
         _buffer.Add(_tmp);
         Assert.AreEqual(i + 1, _buffer.Size, "Size is not equal to number of elements added.");
     }
 }
 public OneToOneSequencedLongArrayThroughputTest()
 {
     _ringBuffer = RingBuffer<long[]>.CreateSingleProducer(() => new long[_arraySize], _bufferSize, new YieldingWaitStrategy());
     var sequenceBarrier = _ringBuffer.NewBarrier();
     _handler = new LongArrayEventHandler();
     _batchEventProcessor = new BatchEventProcessor<long[]>(_ringBuffer, sequenceBarrier, _handler);
     _ringBuffer.AddGatingSequences(_batchEventProcessor.Sequence);
 }
 public void GetDecrementsSize() {
     RingBuffer<int> _buffer = new RingBuffer<int>(iterations);
     populateBuffer(iterations, _buffer);
     for(int i = iterations; i > 0; i--) {
         int _tmp = _buffer.Get();
         Assert.AreEqual(i-1, _buffer.Size, "Size does not reflect the correct number of removed elements.");
     }
 }
		public ICadeDeviceManager()
		{
			timeStep = Mathf.FloorToInt( Time.fixedDeltaTime * 1000.0f );
			bufferSize = 1;
			state = new RingBuffer<ICadeState>( bufferSize );

			device = new ICadeDevice( this );
			devices.Add( device );
		}
 public void IsFullTest_True()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(1);
     rb.Add(2);
     rb.Add(3);
     rb.Add(4);
     Assert.IsTrue(rb.IsFull);
 }
 public void Setup()
 {
     _ringBuffer = new RingBuffer<StubEvent>(()=>new StubEvent(-1), 16);
     _sequenceBarrier = _ringBuffer.NewBarrier();
     _batchHandlerMock = new Mock<IEventHandler<StubEvent>>();
     _countDownEvent = new CountdownEvent(1);
     _batchEventProcessor = new BatchEventProcessor<StubEvent>(_ringBuffer, _sequenceBarrier, _batchHandlerMock.Object);
     _ringBuffer.AddGatingSequences(_batchEventProcessor.Sequence);
 }
 public Sensor(SensorIdentification config)
 {
     mID = config.Id;
     mMAC = config.Mac;
     mPortName = config.PortName;
     mData = new RingBuffer<SensorDataEntry>(HISTORY_BUFFER_SIZE);
     /** Add an empty entry in case getLastEntry is called before data comes in */
     mData.Add( new SensorDataEntry() );
     mTimeoutWatch = new System.Diagnostics.Stopwatch();
 }
        public UniCast1P1CDisruptorPerfTest()
            : base(100 * Million)
        {
            _disruptor = new Disruptor<ValueEvent>(() => new ValueEvent(),BufferSize,TaskScheduler.Default, ProducerType.SINGLE,new YieldingWaitStrategy());                                                         

            _mru = new ManualResetEvent(false);
            _eventHandler = new ValueAdditionEventHandler(Iterations, _mru);
            _disruptor.HandleEventsWith(_eventHandler);
            _ringBuffer = _disruptor.GetRingBuffer;
        }
Beispiel #26
0
 public void AddingToARingBufferWorks()
 {
     RingBuffer<int> r = new RingBuffer<int>(5);
     r.Add(1);
     r.Add(2);
     r.Add(3);
     r.Add(4);
     r.Add(5);
     r.Add(6);
 }
        public void SetUp()
        {
            _ringBuffer = new RingBuffer<StubEvent>(()=>new StubEvent(-1), 64);

            _eventProcessorMock1 = new Mock<IEventProcessor>();
            _eventProcessorMock2 = new Mock<IEventProcessor>();
            _eventProcessorMock3 = new Mock<IEventProcessor>();

            _ringBuffer.SetGatingSequences(new NoOpEventProcessor(_ringBuffer).Sequence);
        }
        public void SetUp()
        {
            _ringBuffer = RingBuffer<StubEvent>.CreateMultiProducer(() => new StubEvent(-1), 64);

            _eventProcessorMock1 = new Mock<IEventProcessor>();
            _eventProcessorMock2 = new Mock<IEventProcessor>();
            _eventProcessorMock3 = new Mock<IEventProcessor>();

            _ringBuffer.AddGatingSequences(new NoOpEventProcessor<StubEvent>(_ringBuffer).Sequence);
        }
 public LongArrayPublisher(Barrier cyclicBarrier,
                      RingBuffer<long[]> ringBuffer,
                       long iterations,
                       long arraySize)
 {
     this.cyclicBarrier = cyclicBarrier;
     this.ringBuffer = ringBuffer;
     this.iterations = iterations;
     this.arraySize = arraySize;
 }
 public ValueBatchPublisher(Barrier cyclicBarrier
 , RingBuffer<ValueEvent> ringBuffer
 , long iterations
 , int batchSize)
 {
     this.cyclicBarrier = cyclicBarrier;
     this.ringBuffer = ringBuffer;
     this.iterations = iterations;
     this.batchSize = batchSize;
 }