2013-08-12 21:10:21 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
2013-08-12 21:50:48 +00:00
|
|
|
#include <cstdlib>
|
2013-08-12 21:10:21 +00:00
|
|
|
#include <thread>
|
|
|
|
#include <iostream>
|
|
|
|
#include <mutex>
|
|
|
|
#include <vector>
|
|
|
|
|
2013-09-10 20:50:35 +00:00
|
|
|
void foo() {
|
2013-08-12 21:10:21 +00:00
|
|
|
static thread_local std::vector<int> v(1024);
|
|
|
|
if (v.size() != 1024) {
|
|
|
|
std::cerr << "Error\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tst1() {
|
|
|
|
unsigned n = 5;
|
|
|
|
for (unsigned i = 0; i < n; i++) {
|
|
|
|
std::thread t([](){ foo(); });
|
|
|
|
t.join();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
tst1();
|
|
|
|
}
|