WebKit Bugzilla
Attachment 339674 Details for
Bug 185361
: [WTF] Use static initializers for WTF::Mutex and WTF::ThreadCondition
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185361-20180506171053.patch (text/plain), 4.11 KB, created by
Yusuke Suzuki
on 2018-05-06 01:10:54 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-05-06 01:10:54 PDT
Size:
4.11 KB
patch
obsolete
>Subversion Revision: 231399 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index b2bea75c04d9732b15e5a64daf9d3a7cd65c2d11..dfdb0cae56c7edc0e5bb43e606dbf88d9537bb0e 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,21 @@ >+2018-05-06 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ [WTF] Use static initializers for WTF::Mutex and WTF::ThreadCondition >+ https://bugs.webkit.org/show_bug.cgi?id=185361 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Use static initializers for WTF::Mutex and WTF::ThreadCondition to make >+ constructors of them simple and constexpr. >+ >+ * wtf/ThreadingPrimitives.h: >+ * wtf/ThreadingPthreads.cpp: >+ (WTF::Mutex::Mutex): Deleted. >+ (WTF::ThreadCondition::ThreadCondition): Deleted. >+ * wtf/ThreadingWin.cpp: >+ (WTF::Mutex::Mutex): Deleted. >+ (WTF::ThreadCondition::ThreadCondition): Deleted. >+ > 2018-05-04 Tim Horton <timothy_horton@apple.com> > > Shift to a lower-level framework for simplifying URLs >diff --git a/Source/WTF/wtf/ThreadingPrimitives.h b/Source/WTF/wtf/ThreadingPrimitives.h >index fdf607fb3d87943df3eb6867183a09cb8bb96ddc..7f20bc99b1c8e3a655c0a4cb572747863eb8b95e 100644 >--- a/Source/WTF/wtf/ThreadingPrimitives.h >+++ b/Source/WTF/wtf/ThreadingPrimitives.h >@@ -65,7 +65,7 @@ class Mutex { > WTF_MAKE_NONCOPYABLE(Mutex); > WTF_MAKE_FAST_ALLOCATED; > public: >- WTF_EXPORT_PRIVATE Mutex(); >+ constexpr Mutex() = default; > WTF_EXPORT_PRIVATE ~Mutex(); > > WTF_EXPORT_PRIVATE void lock(); >@@ -75,7 +75,11 @@ class Mutex { > PlatformMutex& impl() { return m_mutex; } > > private: >- PlatformMutex m_mutex; >+#if USE(PTHREADS) >+ PlatformMutex m_mutex = PTHREAD_MUTEX_INITIALIZER; >+#elif OS(WINDOWS) >+ PlatformMutex m_mutex = SRWLOCK_INIT; >+#endif > }; > > typedef Locker<Mutex> MutexLocker; >@@ -84,7 +88,7 @@ class ThreadCondition { > WTF_MAKE_NONCOPYABLE(ThreadCondition); > WTF_MAKE_FAST_ALLOCATED; > public: >- WTF_EXPORT_PRIVATE ThreadCondition(); >+ constexpr ThreadCondition() = default; > WTF_EXPORT_PRIVATE ~ThreadCondition(); > > WTF_EXPORT_PRIVATE void wait(Mutex& mutex); >@@ -94,7 +98,11 @@ class ThreadCondition { > WTF_EXPORT_PRIVATE void broadcast(); > > private: >- PlatformCondition m_condition; >+#if USE(PTHREADS) >+ PlatformCondition m_condition = PTHREAD_COND_INITIALIZER; >+#elif OS(WINDOWS) >+ PlatformCondition m_condition = CONDITION_VARIABLE_INIT; >+#endif > }; > > } // namespace WTF >diff --git a/Source/WTF/wtf/ThreadingPthreads.cpp b/Source/WTF/wtf/ThreadingPthreads.cpp >index 80b1212581c0692d5e5a462ad49363280683a4f5..a3f428c8c98b7c9dc13ed910812fb95fcd8a783d 100644 >--- a/Source/WTF/wtf/ThreadingPthreads.cpp >+++ b/Source/WTF/wtf/ThreadingPthreads.cpp >@@ -490,18 +490,6 @@ void Thread::destructTLS(void* data) > #endif > } > >-Mutex::Mutex() >-{ >- pthread_mutexattr_t attr; >- pthread_mutexattr_init(&attr); >- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); >- >- int result = pthread_mutex_init(&m_mutex, &attr); >- ASSERT_UNUSED(result, !result); >- >- pthread_mutexattr_destroy(&attr); >-} >- > Mutex::~Mutex() > { > int result = pthread_mutex_destroy(&m_mutex); >@@ -533,11 +521,6 @@ void Mutex::unlock() > ASSERT_UNUSED(result, !result); > } > >-ThreadCondition::ThreadCondition() >-{ >- pthread_cond_init(&m_condition, NULL); >-} >- > ThreadCondition::~ThreadCondition() > { > pthread_cond_destroy(&m_condition); >diff --git a/Source/WTF/wtf/ThreadingWin.cpp b/Source/WTF/wtf/ThreadingWin.cpp >index 4e65a5e4277e4419e806652979695315998a56ee..e1ae74ef71d018148ed13fa0ed222a4b0778beb3 100644 >--- a/Source/WTF/wtf/ThreadingWin.cpp >+++ b/Source/WTF/wtf/ThreadingWin.cpp >@@ -360,11 +360,6 @@ void Thread::destructTLS(void* data) > thread->m_isDestroyedOnce = true; > } > >-Mutex::Mutex() >-{ >- InitializeSRWLock(&m_mutex); >-} >- > Mutex::~Mutex() > { > } >@@ -400,11 +395,6 @@ static DWORD absoluteTimeToWaitTimeoutInterval(WallTime absoluteTime) > return static_cast<DWORD>((absoluteTime - currentTime).milliseconds()); > } > >-ThreadCondition::ThreadCondition() >-{ >- InitializeConditionVariable(&m_condition); >-} >- > ThreadCondition::~ThreadCondition() > { > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185361
: 339674