diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 20:06:30 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 20:06:30 +0000 |
commit | 20f0487a5b73e8071af2612150301b0942cbf0e2 (patch) | |
tree | ecee69b28f16712bdc1558ac0a015ac80095c761 /base | |
parent | 167b0dd17d5ed57ff293b6480ccaed706e0bc9cb (diff) | |
download | chromium_src-20f0487a5b73e8071af2612150301b0942cbf0e2.zip chromium_src-20f0487a5b73e8071af2612150301b0942cbf0e2.tar.gz chromium_src-20f0487a5b73e8071af2612150301b0942cbf0e2.tar.bz2 |
FBTF: Move ctors/dtors into implementation files. Adds ctors/dtors to non-POD structs.
Cuts ~2MB off our .a files (Debug, Linux). Also added the "virtual" keyword on
a whole bunch of virtual dtors that were missing it.
BUG=none
TEST=compiles
Review URL: http://codereview.chromium.org/3522004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61100 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/simple_thread.cc | 35 | ||||
-rw-r--r-- | base/simple_thread.h | 22 |
2 files changed, 42 insertions, 15 deletions
diff --git a/base/simple_thread.cc b/base/simple_thread.cc index bd97369..086a430 100644 --- a/base/simple_thread.cc +++ b/base/simple_thread.cc @@ -37,17 +37,52 @@ void SimpleThread::ThreadMain() { Run(); } +SimpleThread::SimpleThread(const std::string& name_prefix) + : name_prefix_(name_prefix), name_(name_prefix), + thread_(), event_(true, false), tid_(0), joined_(false) { +} + +SimpleThread::SimpleThread(const std::string& name_prefix, + const Options& options) + : name_prefix_(name_prefix), name_(name_prefix), options_(options), + thread_(), event_(true, false), tid_(0), joined_(false) { +} + SimpleThread::~SimpleThread() { DCHECK(HasBeenStarted()) << "SimpleThread was never started."; DCHECK(HasBeenJoined()) << "SimpleThread destroyed without being Join()ed."; } +DelegateSimpleThread::DelegateSimpleThread(Delegate* delegate, + const std::string& name_prefix) + : SimpleThread(name_prefix), + delegate_(delegate) { +} + +DelegateSimpleThread::DelegateSimpleThread(Delegate* delegate, + const std::string& name_prefix, + const Options& options) + : SimpleThread(name_prefix, options), + delegate_(delegate) { +} + +DelegateSimpleThread::~DelegateSimpleThread() { +} + void DelegateSimpleThread::Run() { DCHECK(delegate_) << "Tried to call Run without a delegate (called twice?)"; delegate_->Run(); delegate_ = NULL; } +DelegateSimpleThreadPool::DelegateSimpleThreadPool( + const std::string& name_prefix, + int num_threads) + : name_prefix_(name_prefix), + num_threads_(num_threads), + dry_(true, false) { +} + DelegateSimpleThreadPool::~DelegateSimpleThreadPool() { DCHECK(threads_.empty()); DCHECK(delegates_.empty()); diff --git a/base/simple_thread.h b/base/simple_thread.h index 40e568a..13c46c0 100644 --- a/base/simple_thread.h +++ b/base/simple_thread.h @@ -74,12 +74,8 @@ class SimpleThread : public PlatformThread::Delegate { // configuration involving the thread creation and management. // Every thread has a name, in the form of |name_prefix|/TID, for example // "my_thread/321". The thread will not be created until Start() is called. - explicit SimpleThread(const std::string& name_prefix) - : name_prefix_(name_prefix), name_(name_prefix), - thread_(), event_(true, false), tid_(0), joined_(false) { } - SimpleThread(const std::string& name_prefix, const Options& options) - : name_prefix_(name_prefix), name_(name_prefix), options_(options), - thread_(), event_(true, false), tid_(0), joined_(false) { } + explicit SimpleThread(const std::string& name_prefix); + SimpleThread(const std::string& name_prefix, const Options& options); virtual ~SimpleThread(); @@ -127,14 +123,12 @@ class DelegateSimpleThread : public SimpleThread { }; DelegateSimpleThread(Delegate* delegate, - const std::string& name_prefix) - : SimpleThread(name_prefix), delegate_(delegate) { } + const std::string& name_prefix); DelegateSimpleThread(Delegate* delegate, const std::string& name_prefix, - const Options& options) - : SimpleThread(name_prefix, options), delegate_(delegate) { } + const Options& options); - virtual ~DelegateSimpleThread() { } + virtual ~DelegateSimpleThread(); virtual void Run(); private: Delegate* delegate_; @@ -153,10 +147,8 @@ class DelegateSimpleThreadPool : public DelegateSimpleThread::Delegate { public: typedef DelegateSimpleThread::Delegate Delegate; - DelegateSimpleThreadPool(const std::string& name_prefix, int num_threads) - : name_prefix_(name_prefix), num_threads_(num_threads), - dry_(true, false) { } - ~DelegateSimpleThreadPool(); + DelegateSimpleThreadPool(const std::string& name_prefix, int num_threads); + virtual ~DelegateSimpleThreadPool(); // Start up all of the underlying threads, and start processing work if we // have any. |