-- assert fixes for thrift concurrency lib
Summary:
- cannot assume that assert.h is defined
Reviewed By: marc k
Test Plan: everything compiles
Notes:
- need to reflect these changes in libfacebook/fbthread
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665073 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
index d5d0d06..a043418 100644
--- a/lib/cpp/src/concurrency/PosixThreadFactory.cpp
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
@@ -68,25 +68,32 @@
state_ = starting;
pthread_attr_t thread_attr;
- assert(pthread_attr_init(&thread_attr) == 0);
- assert(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE) == 0);
+ int ret = pthread_attr_init(&thread_attr);
+ assert(ret);
+
+ ret = pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE);
+ assert(ret);
// Set thread stack size
- assert(pthread_attr_setstacksize(&thread_attr, MB * stackSize_) == 0);
+ ret = pthread_attr_setstacksize(&thread_attr, MB * stackSize_);
+ assert(ret);
// Set thread policy
- assert(pthread_attr_setschedpolicy(&thread_attr, policy_) == 0);
+ ret = pthread_attr_setschedpolicy(&thread_attr, policy_);
+ assert(ret);
struct sched_param sched_param;
sched_param.sched_priority = priority_;
// Set thread priority
- assert(pthread_attr_setschedparam(&thread_attr, &sched_param) == 0);
+ ret = pthread_attr_setschedparam(&thread_attr, &sched_param);
+ assert(ret);
// Create reference
shared_ptr<PthreadThread>* selfRef = new shared_ptr<PthreadThread>();
*selfRef = self_.lock();
- assert(pthread_create(&pthread_, &thread_attr, threadMain, (void*)selfRef) == 0);
+ ret = pthread_create(&pthread_, &thread_attr, threadMain, (void*)selfRef);
+ assert(ret);
}
void join() {
@@ -101,7 +108,8 @@
void runnable(shared_ptr<Runnable> value) { Thread::runnable(value); }
void weakRef(shared_ptr<PthreadThread> self) {
- assert(self.get() == this);
+ bool ret = (self.get() == this);
+ assert(ret);
self_ = weak_ptr<PthreadThread>(self);
}
};