add an unlock() method to Synchronized<T>::LockedPtr
authorAdam Simpkins <simpkins@fb.com>
Wed, 27 Jul 2016 19:32:20 +0000 (12:32 -0700)
committerFacebook Github Bot 7 <facebook-github-bot-7-bot@fb.com>
Wed, 27 Jul 2016 19:38:32 +0000 (12:38 -0700)
commit382372728d0f77c8d430577ea4cf77b53a56a4de
tree3ae4637a94be86c8cf8e768a2707f0691c340e3e
parent5d90c1385188d4632ce9a0f0e6bc5b83d4cf5138
add an unlock() method to Synchronized<T>::LockedPtr

Summary:
Add an unlock() method to Synchronized LockedPtr objects.  This will make it
easier to replace current users of the UNSYNCHRONIZED macro.

Of the handful of places currently using UNSYNCHRONIZED, many of them want to
simply release the lock before logging a message and returning.  However,
UNSYNCHRONIZED is a poor choice for this, since it will re-acquire the lock on
scope exit.  In these situations where the function returns from inside an
UNSYNCHRONIZED block the code unnecessarily re-acquires the lock just to
immediately release it.  The unlock() method will provide a cleaner mechanism
for these call sites to simply drop the lock early before returning.

Reviewed By: yfeldblum

Differential Revision: D3547652

fbshipit-source-id: 4d28fe9f3aad0d7348e918d1a3d6c705bfec242b
folly/Synchronized.h
folly/test/SynchronizedTest.cpp
folly/test/SynchronizedTestLib-inl.h