SpinLock improvements
authorAdam Simpkins <simpkins@fb.com>
Fri, 12 Dec 2014 02:22:37 +0000 (18:22 -0800)
committerJoelMarcey <joelm@fb.com>
Thu, 18 Dec 2014 20:29:40 +0000 (12:29 -0800)
commite4ef6050fb8b853f1ff21a141448b1c1aeca574c
tree8429d3a2b695a4b630f398cf774ae0459e4d9880
parent6b3d35fce341c09593ee7f3c6e0a00f34c7a7380
SpinLock improvements

Summary:
This makes several improvements to the SpinLock code:

- Add a SpinLock implementation using pthread_spinlock_t.  On non-x86_64
platforms this is preferred over the pthread_mutex_t implementation
when available.

- For the pthread implementations, throw std::system_error on error,
rather than completely aborting the program using glog's CHECK()
macros.

- Update the pthread_mutex_t implementation to call
pthread_mutex_destroy() on destruction.

- Always unit test all implementations that can be compiled on the
current build platform, even though only a single implementation will
be selected as folly::SpinLock.  This way x86_64 builds will still
unit test the pthread-based implementations.

Test Plan: Ran the unit tests.

Reviewed By: seanc@fb.com

Subscribers: trunkagent, doug, net-systems@, exa, folly-diffs@

FB internal diff: D1735770

Signature: t1:1735770:1418445953:b238aa8fb835a8d55e6e98e20c4615ae1938b98f
folly/Makefile.am
folly/SpinLock.h
folly/detail/SpinLockImpl.h [new file with mode: 0644]
folly/test/SpinLockTest.cpp