Add missing methods to thread_posix.cc
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@847 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: eff5afef66d05fee94cc377512e2e8e21019421a
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::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 @@
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();
+}