diff options
author | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-28 01:17:02 +0000 |
---|---|---|
committer | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-28 01:17:02 +0000 |
commit | 6e683db29d1f0d8c90faf03d37f7a14ad9d55f8d (patch) | |
tree | 67070a5e595dd5646b61edc6c2337f793f53dbca /base/platform_thread_posix.cc | |
parent | 4d5e036157b6fa024f0a7e0659c0559bbfc8dfcb (diff) | |
download | chromium_src-6e683db29d1f0d8c90faf03d37f7a14ad9d55f8d.zip chromium_src-6e683db29d1f0d8c90faf03d37f7a14ad9d55f8d.tar.gz chromium_src-6e683db29d1f0d8c90faf03d37f7a14ad9d55f8d.tar.bz2 |
Ensure Cocoa sets up its multithreaded environment
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/platform_thread_posix.cc')
-rw-r--r-- | base/platform_thread_posix.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/base/platform_thread_posix.cc b/base/platform_thread_posix.cc index 760ce1c..77f5bee 100644 --- a/base/platform_thread_posix.cc +++ b/base/platform_thread_posix.cc @@ -14,6 +14,12 @@ #include <unistd.h> #endif +#if defined(OS_MACOSX) +namespace base { +void InitThreading(); +} // namespace +#endif + static void* ThreadFunc(void* closure) { PlatformThread::Delegate* delegate = static_cast<PlatformThread::Delegate*>(closure); @@ -65,18 +71,22 @@ void PlatformThread::SetName(const char* name) { // static bool PlatformThread::Create(size_t stack_size, Delegate* delegate, PlatformThreadHandle* thread_handle) { +#if defined(OS_MACOSX) + base::InitThreading(); +#endif // OS_MACOSX + bool success = false; pthread_attr_t attributes; pthread_attr_init(&attributes); // Pthreads are joinable by default, so we don't need to specify any special // attributes to be able to call pthread_join later. - + if (stack_size > 0) pthread_attr_setstacksize(&attributes, stack_size); success = !pthread_create(thread_handle, &attributes, ThreadFunc, delegate); - + pthread_attr_destroy(&attributes); return success; } @@ -85,4 +95,3 @@ bool PlatformThread::Create(size_t stack_size, Delegate* delegate, void PlatformThread::Join(PlatformThreadHandle thread_handle) { pthread_join(thread_handle, NULL); } - |