From: Mark Slee Date: Wed, 23 May 2007 04:55:30 +0000 (+0000) Subject: mcslee: being nitpicky ensuring consistent coding style X-Git-Tag: 0.2.0~1350 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=2782d6d205344fc6b02f30c674812bd91bcff2a1;p=common%2Fthrift.git 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 0177a0c0..8517c03c 100644 --- a/lib/cpp/src/concurrency/Monitor.cpp +++ b/lib/cpp/src/concurrency/Monitor.cpp @@ -31,15 +31,15 @@ class Monitor::Impl { 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 @@ class Monitor::Impl { &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 e4334672..5f86ea27 100644 --- a/lib/cpp/src/concurrency/PosixThreadFactory.cpp +++ b/lib/cpp/src/concurrency/PosixThreadFactory.cpp @@ -69,38 +69,38 @@ class PthreadThread: public Thread { 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* selfRef = new shared_ptr(); *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 @@ class PosixThreadFactory::Impl { 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 @@ PosixThreadFactory::PRIORITY PosixThreadFactory::priority() const { return impl_ 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 4e31dc50..5f032c1c 100644 --- a/lib/cpp/src/concurrency/PosixThreadFactory.h +++ b/lib/cpp/src/concurrency/PosixThreadFactory.h @@ -58,7 +58,7 @@ class PosixThreadFactory : public ThreadFactory { boost::shared_ptr newThread(boost::shared_ptr 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 7d78edb2..1260e5aa 100644 --- a/lib/cpp/src/concurrency/ThreadManager.cpp +++ b/lib/cpp/src/concurrency/ThreadManager.cpp @@ -248,8 +248,8 @@ class ThreadManager::Worker: public Runnable { /* 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 @@ void ThreadManager::Impl::removeWorker(size_t value) { 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 @@ void ThreadManager::Impl::remove(shared_ptr task) { class SimpleThreadManager : public ThreadManager::Impl { -public: + public: SimpleThreadManager(size_t workerCount=4, size_t pendingTaskCountMax=0) : workerCount_(workerCount), pendingTaskCountMax_(pendingTaskCountMax), @@ -462,7 +462,7 @@ public: 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 8d6dd5ec..07f05adc 100644 --- a/lib/cpp/src/concurrency/TimerManager.cpp +++ b/lib/cpp/src/concurrency/TimerManager.cpp @@ -98,8 +98,8 @@ class TimerManager::Dispatcher: public Runnable { } 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(); }