cpp: Add profiling hooks to Mutex, ReadWriteMutex() classes
authorDavid Reiss <dreiss@apache.org>
Tue, 9 Mar 2010 05:20:04 +0000 (05:20 +0000)
committerDavid Reiss <dreiss@apache.org>
Tue, 9 Mar 2010 05:20:04 +0000 (05:20 +0000)
commit7a2065d3dbdf361bbbe8b66a5b03080c0e532403
tree35318367c65d8a46400ab0fec57102588e96a095
parent4cc0755b3382abc3e17ebba0ab4c2c78b9a8bbd7
cpp: Add profiling hooks to Mutex, ReadWriteMutex() classes

Extend the Thrift C++ Concurrency library by allowing a user to register
a callback and a sample rate for lock primitive contention profiling.
The callback will be invoked approximately once every sampleRate calls
to Mutex::lock(), Mutex::timedlock(), ReadWriteLock::acquireRead(), or
ReadWriteLock::acquireWrite().

The callback receives a pointer to the mutex responsible and the time
waited on the lock in micros (whether the lock was successfuly acquire
or not).  The user can then implement a registry of his choice to
log/collect this data as needed.

This can all be easily compiled out if it harms performance.  By
default, there is no profiling callback, so the overhead is minimal
(one branch).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920681 13f79535-47bb-0310-9956-ffa450edef68
lib/cpp/src/concurrency/Mutex.cpp
lib/cpp/src/concurrency/Mutex.h
lib/cpp/src/concurrency/Util.cpp
lib/cpp/src/concurrency/Util.h