mcslee: being nitpicky ensuring consistent coding style
Summary: no tabs, conditionals with spaces around them, etc
Reviewed By: thrift style rules
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665122 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/Monitor.cpp b/lib/cpp/src/concurrency/Monitor.cpp
index 0177a0c..8517c03 100644
--- a/lib/cpp/src/concurrency/Monitor.cpp
+++ b/lib/cpp/src/concurrency/Monitor.cpp
@@ -31,15 +31,15 @@
mutexInitialized_(false),
condInitialized_(false) {
- if(pthread_mutex_init(&pthread_mutex_, NULL) == 0) {
+ if (pthread_mutex_init(&pthread_mutex_, NULL) == 0) {
mutexInitialized_ = true;
- if(pthread_cond_init(&pthread_cond_, NULL) == 0) {
+ if (pthread_cond_init(&pthread_cond_, NULL) == 0) {
condInitialized_ = true;
}
}
- if(!mutexInitialized_ || !condInitialized_) {
+ if (!mutexInitialized_ || !condInitialized_) {
cleanup();
throw SystemResourceException();
}
@@ -66,7 +66,7 @@
&pthread_mutex_,
&abstime);
if (result == ETIMEDOUT) {
- assert(Util::currentTime() >= (now + timeout));
+ assert(Util::currentTime() >= (now + timeout));
throw TimedOutException();
}
}
diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
index e433467..5f86ea2 100644
--- a/lib/cpp/src/concurrency/PosixThreadFactory.cpp
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
@@ -69,38 +69,38 @@
state_ = starting;
pthread_attr_t thread_attr;
- if(pthread_attr_init(&thread_attr) != 0) {
+ if (pthread_attr_init(&thread_attr) != 0) {
throw SystemResourceException("pthread_attr_init failed");
}
- if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE) != 0) {
- throw SystemResourceException("pthread_attr_setdetachstate failed");
+ if (pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE) != 0) {
+ throw SystemResourceException("pthread_attr_setdetachstate failed");
}
// Set thread stack size
- if(pthread_attr_setstacksize(&thread_attr, MB * stackSize_) != 0) {
- throw SystemResourceException("pthread_attr_setstacksize failed");
+ if (pthread_attr_setstacksize(&thread_attr, MB * stackSize_) != 0) {
+ throw SystemResourceException("pthread_attr_setstacksize failed");
}
// Set thread policy
- if(pthread_attr_setschedpolicy(&thread_attr, policy_) != 0) {
- throw SystemResourceException("pthread_attr_setschedpolicy failed");
+ if (pthread_attr_setschedpolicy(&thread_attr, policy_) != 0) {
+ throw SystemResourceException("pthread_attr_setschedpolicy failed");
}
struct sched_param sched_param;
sched_param.sched_priority = priority_;
// Set thread priority
- if(pthread_attr_setschedparam(&thread_attr, &sched_param) != 0) {
- throw SystemResourceException("pthread_attr_setschedparam failed");
+ if (pthread_attr_setschedparam(&thread_attr, &sched_param) != 0) {
+ throw SystemResourceException("pthread_attr_setschedparam failed");
}
// Create reference
shared_ptr<PthreadThread>* selfRef = new shared_ptr<PthreadThread>();
*selfRef = self_.lock();
- if(pthread_create(&pthread_, &thread_attr, threadMain, (void*)selfRef) != 0) {
- throw SystemResourceException("pthread_create failed");
+ if (pthread_create(&pthread_, &thread_attr, threadMain, (void*)selfRef) != 0) {
+ throw SystemResourceException("pthread_create failed");
}
}
@@ -223,7 +223,7 @@
PRIORITY priority() const { return priority_; }
- Thread::id_t currentThreadId() const {return pthread_self();}
+ Thread::id_t currentThreadId() const { return pthread_self(); }
/**
* Sets priority.
@@ -247,6 +247,6 @@
void PosixThreadFactory::priority(PosixThreadFactory::PRIORITY value) { impl_->priority(value); }
-Thread::id_t PosixThreadFactory::currentThreadId() const {return impl_->currentThreadId();}
+Thread::id_t PosixThreadFactory::currentThreadId() const { return impl_->currentThreadId(); }
}}} // facebook::thrift::concurrency
diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.h b/lib/cpp/src/concurrency/PosixThreadFactory.h
index 4e31dc5..5f032c1 100644
--- a/lib/cpp/src/concurrency/PosixThreadFactory.h
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.h
@@ -58,7 +58,7 @@
boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
// From ThreadFactory;
- Thread::id_t currentThreadId() const;
+ Thread::id_t currentThreadId() const;
/**
* Sets stack size for created threads
diff --git a/lib/cpp/src/concurrency/ThreadManager.cpp b/lib/cpp/src/concurrency/ThreadManager.cpp
index 7d78edb..1260e5a 100644
--- a/lib/cpp/src/concurrency/ThreadManager.cpp
+++ b/lib/cpp/src/concurrency/ThreadManager.cpp
@@ -248,8 +248,8 @@
/* If we have a pending task max and we just dropped below it, wakeup any
thread that might be blocked on add. */
- if(manager_->pendingTaskCountMax_ != 0 &&
- manager_->tasks_.size() == manager_->pendingTaskCountMax_ - 1) {
+ if (manager_->pendingTaskCountMax_ != 0 &&
+ manager_->tasks_.size() == manager_->pendingTaskCountMax_ - 1) {
manager_->workerMonitor_.notify();
}
}
@@ -419,11 +419,11 @@
throw IllegalStateException();
}
- if(pendingTaskCountMax_ > 0 && (tasks_.size() >= pendingTaskCountMax_)) {
+ if (pendingTaskCountMax_ > 0 && (tasks_.size() >= pendingTaskCountMax_)) {
- if(canSleep()) {
+ if (canSleep()) {
- while(pendingTaskCountMax_ > 0 && tasks_.size() >= pendingTaskCountMax_) {
+ while (pendingTaskCountMax_ > 0 && tasks_.size() >= pendingTaskCountMax_) {
monitor_.wait(timeout);
}
} else {
@@ -449,7 +449,7 @@
class SimpleThreadManager : public ThreadManager::Impl {
-public:
+ public:
SimpleThreadManager(size_t workerCount=4, size_t pendingTaskCountMax=0) :
workerCount_(workerCount),
pendingTaskCountMax_(pendingTaskCountMax),
@@ -462,7 +462,7 @@
addWorker(workerCount_);
}
-private:
+ private:
const size_t workerCount_;
const size_t pendingTaskCountMax_;
bool firstTime_;
diff --git a/lib/cpp/src/concurrency/TimerManager.cpp b/lib/cpp/src/concurrency/TimerManager.cpp
index 8d6dd5e..07f05ad 100644
--- a/lib/cpp/src/concurrency/TimerManager.cpp
+++ b/lib/cpp/src/concurrency/TimerManager.cpp
@@ -98,8 +98,8 @@
}
assert((timeout != 0 && manager_->taskCount_ > 0) || (timeout == 0 && manager_->taskCount_ == 0));
try {
- manager_->monitor_.wait(timeout);
- } catch(TimedOutException& e) {}
+ manager_->monitor_.wait(timeout);
+ } catch (TimedOutException &e) {}
now = Util::currentTime();
}