add LockTraits
Summary:
This adds a new LockTraits template class, for specifying how to use arbitrary
custom mutex types.
The goal of this new class is to replace the acquireRead(), acquireReadWrite(),
releaseRead(), and releaseReadWrite() functions currently defined in
Synchronized.h. I have not replaced these functions yet in this diff, but will
do so in a follow-up diff.
LockTraits has a few advantages over the existing methods:
* It provides mechanisms for telling if a given mutex supports shared access
and timed access.
* The default LockTraits implementation automatically figures out the correct
behavior for classes that define lock(), unlock(), methods. It automatically
detects sharing and timed support based on the presence of lock_shared() and
try_lock_for() methods.
LockTraits can be specialized for custom lock types that do not conform with
the lock method names used by the C++ standard. This does differ slightly from
the argument dependent lookup mechanism used by the acquireRead() functions.
Reviewed By: yfeldblum
Differential Revision:
D3504625
fbshipit-source-id:
40320997e9ae2147baecd10b70e8dc06a35e49e1