AtomicStruct<T> provides atomic ops on small trivial classes
authorNathan Bronson <ngbronson@fb.com>
Thu, 19 Dec 2013 18:37:56 +0000 (10:37 -0800)
committerJordan DeLong <jdelong@fb.com>
Fri, 20 Dec 2013 21:07:32 +0000 (13:07 -0800)
commit790628410e0afadcc904a25e4e855bfd53054099
tree4d8313b5562ce9634271cb9205fa5ec022818e3b
parenta91e75dbf16f3f3e038dbd828efedd9916d59bf9
AtomicStruct<T> provides atomic ops on small trivial classes

Summary:
AtomicStruct<T> acts like std::atomic<T>, but it supports any
trivial or trivially-copyable type up to 8 bytes in size.  I'm not sure
why these types weren't included in the original std::atomic standard,
since this construct removes a lot of boilerplate for some uses of
std::atomic.

Test Plan:
1. unit tests
2. this code is adapted from production use in tao/queues/LifoSem

Reviewed By: davejwatson@fb.com

FB internal diff: D1085106
folly/AtomicStruct.h [new file with mode: 0644]
folly/Makefile.am
folly/test/AtomicStructTest.cpp [new file with mode: 0644]