void SensorRouter::routeData(Data d) {
  // Attempt to acquire a lock on the Mutex, but give up 
  // if the invocation timeout threshold is passed
  if(_mutex->try_lock(10000)) {
    // Send the data out to the various data sinks for processing
    // ....
    _mutex->unlock();  // Release the Mutex lock
  }
}

Example 6: Using the Mutex to lock a section of code.

Back to Article