diff options
author | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-14 00:47:51 +0000 |
---|---|---|
committer | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-14 00:47:51 +0000 |
commit | eff5afef66d05fee94cc377512e2e8e21019421a (patch) | |
tree | f3c6008fac200dccfa3e1db0c5ac6ef1edbd9284 | |
parent | 5115474e2e2c773b53fc1e111426e8924deeadb7 (diff) | |
download | chromium_src-eff5afef66d05fee94cc377512e2e8e21019421a.zip chromium_src-eff5afef66d05fee94cc377512e2e8e21019421a.tar.gz chromium_src-eff5afef66d05fee94cc377512e2e8e21019421a.tar.bz2 |
Add missing methods to thread_posix.cc
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@847 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/thread_posix.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/base/thread_posix.cc b/base/thread_posix.cc index e04ebcb..11b98bf 100644 --- a/base/thread_posix.cc +++ b/base/thread_posix.cc @@ -79,11 +79,24 @@ bool Thread::GetThreadWasQuitProperly() { bool Thread::Start() { + return StartWithStackSize(0); +} + +bool Thread::StartWithStackSize(size_t stack_size) { bool success = false; - int result = pthread_create(&thread_id_, NULL, ThreadFunc, &message_loop_); + pthread_attr_t attributes; + pthread_attr_init(&attributes); + + // A stack size smaller than PTHREAD_STACK_MIN won't change the default value. + pthread_attr_setstacksize(&attributes, stack_size); + int result = pthread_create(&thread_id_, + &attributes, + ThreadFunc, + &message_loop_); if (!result) success = true; + pthread_attr_destroy(&attributes); return success; } @@ -100,3 +113,9 @@ void Thread::Stop() { message_loop_ = NULL; } + +void Thread::StopSoon() { + // TODO(paulg): Make Thread::Stop block on thread join, and Thread::StopSoon + // return immediately after calling (like the Windows versions). + Stop(); +} |