Commit bb4612a0 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Alecs King

clang:dev rejects vector<atomic<T>> in EventBaseTest.cpp.

Summary: [Folly] clang:dev rejects vector<atomic<T>> in EventBaseTest.cpp.

Test Plan: Build and run `folly/io/async/test/EventBaseTest.cpp` using the current `clang`; try building with `clang:dev` and verifying that at least the related failures are gone.

Reviewed By: meyering@fb.com

Subscribers: mathieubaudet, folly-diffs@, yfeldblum, dougw, brettp

FB internal diff: D1848749

Tasks: 6244720

Signature: t1:1848749:1423866420:7b7354d4568b6a6d6a824236ae8d271f6855d90b
parent 0234d5d1
......@@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <folly/Memory.h>
#include <folly/io/async/AsyncTimeout.h>
#include <folly/io/async/EventBase.h>
#include <folly/io/async/EventHandler.h>
......@@ -32,6 +34,7 @@ using std::atomic;
using std::deque;
using std::pair;
using std::vector;
using std::unique_ptr;
using std::thread;
using std::make_pair;
using std::cerr;
......@@ -1179,14 +1182,14 @@ TEST(EventBaseTest, RunInThread) {
// whether any of the race conditions happened.
TEST(EventBaseTest, RunInEventLoopThreadAndWait) {
const size_t c = 256;
vector<atomic<size_t>> atoms(c);
vector<unique_ptr<atomic<size_t>>> atoms(c);
for (size_t i = 0; i < c; ++i) {
auto& atom = atoms.at(i);
atom = 0;
atom = make_unique<atomic<size_t>>(0);
}
vector<thread> threads(c);
for (size_t i = 0; i < c; ++i) {
auto& atom = atoms.at(i);
auto& atom = *atoms.at(i);
auto& th = threads.at(i);
th = thread([&atom] {
EventBase eb;
......@@ -1209,7 +1212,7 @@ TEST(EventBaseTest, RunInEventLoopThreadAndWait) {
th.join();
}
size_t sum = 0;
for (auto& atom : atoms) sum += atom;
for (auto& atom : atoms) sum += *atom;
EXPECT_EQ(c, sum);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment