Fix HHWheelTimer compilation bug in libc++ build
authorPeter Griess <pgriess@fb.com>
Tue, 6 Jan 2015 20:30:32 +0000 (12:30 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:04 +0000 (11:01 -0800)
Summary:
- Manually swap bucket_ entries in HHWheelTimer to work around a bug in
libc++

Test Plan:
- fbconfig -r folly/io/async && fbmake runtests --extended-tests
- Sync to OS X and build there

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, doug, seanc, folly-diffs@

FB internal diff: D1766601

Signature: t1:1766601:1420566916:24a2911e997ee04f0934884bdf7b82345cb2b752

folly/io/async/HHWheelTimer.cpp

index d762224891d565875918a9872caf3b7fe78cc9ca..aab67784d81a30a9a78fb571594b1e1a8ea35f5a 100644 (file)
@@ -205,7 +205,20 @@ void HHWheelTimer::timeoutExpired() noexcept {
 
 size_t HHWheelTimer::cancelAll() {
   decltype(buckets_) buckets;
+
+// Work around std::swap() bug in libc++
+//
+// http://llvm.org/bugs/show_bug.cgi?id=22106
+#if FOLLY_USE_LIBCPP
+  for (size_t i = 0; i < WHEEL_BUCKETS; ++i) {
+    for (size_t ii = 0; i < WHEEL_SIZE; ++ii) {
+      std::swap(buckets_[i][ii], buckets[i][ii]);
+    }
+  }
+#else
   std::swap(buckets, buckets_);
+#endif
+
   size_t count = 0;
 
   for (auto& tick : buckets) {