Пример #1
0
    /// <summary>
    /// Multithreaded counterpart of SetNewDatum(), this gets the newest datum.
    /// </summary>
    EyeDatum _getNewDatum()
    {
      EyeDatum datum = null;

      if (_pendingDatum)
      {
        //acquire new data and push it
        lock (_newDatumLock)
        {
          //copy the newest datum
          datum = new EyeDatum(_newestDatum);
          _pendingDatum = false;
        }
      }

      return datum;
    }
Пример #2
0
 public EyeDatum(EyeDatum datum)
 {
   MouseData = datum.MouseData;
   TimeStamp = datum.TimeStamp;
 }
Пример #3
0
    /// <summary>
    /// Multi-threaded symmetic counterpart of GetNewDatum. Set _newestDatum to the
    /// current MouseState. Old datum is simply overwritten. The motivation for this design
    /// is so that the sensor-data history data structure does not need to be blocking.
    /// The consumer thread runs computations as fast as it can upon the most recent data, but
    /// neither thread should block because of pending data.
    /// 
    /// TODO: evaluate if only changed data should be added; if mouse state has not changed within
    /// a very brief time interval, the mouse state likely has not changed.
    /// </summary>
    void _setNewDatum()
    {
      lock (_newDatumLock)
      {
        if (_pendingDatum)
        {
          //increment misses; this is just for debugging how poorly the consumer is consuming new data.
          _misses++;
        }

        _newestDatum = new EyeDatum(Mouse.GetState(), DateTime.Now);
        _pendingDatum = true;
      }
    }