summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel/parallel-test.cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-08-28 02:50:02 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-08-28 02:50:02 +0000
commit29edc4e6fb2c8fb3a93aac36d9666efd21b92bd0 (patch)
tree2b1998d904a16cdce69f69041c89cc56d474e69e /sca-cpp/trunk/kernel/parallel-test.cpp
parentd93ec216d63aed8ff2f08b4cba7de965dc14639c (diff)
Implement a portable alternative to __thread and get the HTTP and SQLDB components and the Auth modules working with the HTTPD multithreaded event MPM.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1162472 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/kernel/parallel-test.cpp')
-rw-r--r--sca-cpp/trunk/kernel/parallel-test.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/sca-cpp/trunk/kernel/parallel-test.cpp b/sca-cpp/trunk/kernel/parallel-test.cpp
index ab832f1472..f883d19f69 100644
--- a/sca-cpp/trunk/kernel/parallel-test.cpp
+++ b/sca-cpp/trunk/kernel/parallel-test.cpp
@@ -71,13 +71,18 @@ struct mutexPerf {
}
};
-__thread int tlsi = 0;
+const gc_ptr<int> tlsic() {
+ gc_ptr<int> i = new (gc_new<int>()) int();
+ *i = 0;
+ return i;
+}
+const perthread_ptr<int> tlsi(tlsic);
struct tlsPerf {
tlsPerf() {
}
const bool operator()() const {
- tlsi = tlsi + 1;
+ *tlsi = *tlsi + 1;
return true;
}
};
@@ -105,7 +110,7 @@ bool testAtomicPerf() {
{
const lambda<bool()> l = tlsPerf();
cout << "Thread local inc test " << time(l, 1000, count) << " ms" << endl;
- assert(tlsi == count + 1000);
+ assert(*tlsi == count + 1000);
}
return true;
}
@@ -131,18 +136,23 @@ bool checkSquareResults(const list<future<int> > r, int i) {
return true;
}
-__thread long int tlsv = 0;
+const gc_ptr<long int> tlsvc() {
+ gc_ptr<long int> i = new (gc_new<long int>()) long int();
+ *i = 0l;
+ return i;
+}
+const perthread_ptr<long int> tlsv(tlsvc);
const long int tlsset(gc_ptr<wqueue<bool>> wq, gc_ptr<wqueue<bool>> xq) {
- const long int v = tlsv;
- tlsv = threadId();
+ const long int v = *tlsv;
+ *tlsv = threadId();
enqueue(*xq, true);
dequeue(*wq);
return v;
}
const bool tlscheck(gc_ptr<wqueue<bool>> wq, gc_ptr<wqueue<bool>> xq) {
- const bool r = tlsv == threadId();
+ const bool r = *tlsv == threadId();
enqueue(*xq, true);
dequeue(*wq);
return r;