Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: ppapi/utility/threading/simple_thread.cc

Issue 12259018: Provide alternate constructor for specifying a simple thread's stacksize. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/utility/threading/simple_thread.cc
===================================================================
--- ppapi/utility/threading/simple_thread.cc (revision 182510)
+++ ppapi/utility/threading/simple_thread.cc (working copy)
@@ -12,6 +12,14 @@
namespace {
+// Use 2MB default stack size for Native Client, otherwise use system default.
+#if defined(__native_client__)
+const size_t kDefaultStackSize = 2 * 1024 * 1024;
+#else
+const size_t kDefaultStackSize = 0;
+#endif
+
+
struct ThreadData {
MessageLoop message_loop;
@@ -41,9 +49,18 @@
SimpleThread::SimpleThread(const InstanceHandle& instance)
: instance_(instance),
message_loop_(instance),
+ stacksize_(kDefaultStackSize),
thread_(0) {
}
+SimpleThread::SimpleThread(const InstanceHandle& instance,
+ const size_t stacksize)
+ : instance_(instance),
+ message_loop_(instance),
+ stacksize_(stacksize),
+ thread_(0) {
+}
+
SimpleThread::~SimpleThread() {
Join();
}
@@ -82,10 +99,15 @@
data->user_data = user_data;
#ifdef WIN32
- thread_ = CreateThread(NULL, 0, &RunThread, data, 0, NULL);
+ thread_ = CreateThread(NULL, stacksize_, &RunThread, data, 0, NULL);
if (!thread_) {
#else
- if (pthread_create(&thread_, NULL, &RunThread, data) != 0) {
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ int setval = 0;
+ if (stacksize_ > 0)
+ setval = pthread_attr_setstacksize(&attr, stacksize_);
+ if (setval != 0 || pthread_create(&thread_, &attr, &RunThread, data) != 0) {
#endif
delete data;
return false;
« ppapi/utility/threading/simple_thread.h ('K') | « ppapi/utility/threading/simple_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698