Changeset 167526 in webkit
- Timestamp:
- Apr 18, 2014 8:23:03 PM (10 years ago)
- Location:
- trunk/Source/bmalloc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r167502 r167526 1 2014-04-18 Geoffrey Garen <ggaren@apple.com> 2 3 bmalloc: AsyncTask should use Mutex instead of std::mutex 4 https://bugs.webkit.org/show_bug.cgi?id=131865 5 6 Reviewed by Gavin Barraclough. 7 8 std::mutex is so slow that it makes parallelizing simple tasks through 9 AsyncTask a net regression. Mutex fixes this. 10 11 * bmalloc/AsyncTask.h: 12 (bmalloc::Function>::AsyncTask): 13 (bmalloc::Function>::join): 14 (bmalloc::Function>::runSlowCase): 15 (bmalloc::Function>::entryPoint): 16 * bmalloc/Mutex.h: 17 (bmalloc::Mutex::init): 18 1 19 2014-04-18 Geoffrey Garen <ggaren@apple.com> 2 20 -
trunk/Source/bmalloc/bmalloc/AsyncTask.h
r166956 r167526 29 29 #include "BAssert.h" 30 30 #include "Inline.h" 31 #include "Mutex.h" 31 32 #include <atomic> 32 33 #include <condition_variable> … … 56 57 std::atomic<State> m_state; 57 58 58 std::mutex m_conditionMutex;59 std::condition_variable m_condition;59 Mutex m_conditionMutex; 60 std::condition_variable_any m_condition; 60 61 pthread_t m_thread; 61 62 … … 74 75 , m_function(function) 75 76 { 77 m_conditionMutex.init(); 76 78 } 77 79 … … 82 84 return; 83 85 84 { std::lock_guard< std::mutex> lock(m_conditionMutex); }86 { std::lock_guard<Mutex> lock(m_conditionMutex); } 85 87 m_condition.notify_one(); 86 88 … … 105 107 106 108 if (oldState == Sleeping) { 107 { std::lock_guard< std::mutex> lock(m_conditionMutex); }109 { std::lock_guard<Mutex> lock(m_conditionMutex); } 108 110 m_condition.notify_one(); 109 111 return; … … 132 134 expectedState = Running; 133 135 if (m_state.compare_exchange_weak(expectedState, Sleeping)) { 134 std::unique_lock< std::mutex> lock(m_conditionMutex);136 std::unique_lock<Mutex> lock(m_conditionMutex); 135 137 m_condition.wait_for(lock, exitDelay, [=]() { return this->m_state != Sleeping; }); 136 138 } -
trunk/Source/bmalloc/bmalloc/Mutex.h
r166910 r167526 34 34 namespace bmalloc { 35 35 36 classMutex {36 struct Mutex { 37 37 public: 38 void init(); 39 38 40 void lock(); 39 41 bool try_lock(); … … 45 47 std::atomic_flag m_flag; 46 48 }; 49 50 inline void Mutex::init() 51 { 52 m_flag.clear(); 53 } 47 54 48 55 inline bool Mutex::try_lock()
Note: See TracChangeset
for help on using the changeset viewer.