https://bugs.webkit.org/show_bug.cgi?id=127783
Reviewed by Antti Koivisto.
* wtf/CryptographicallyRandomNumber.cpp:
* wtf/MainThread.cpp:
(WTF::mainThreadFunctionQueueMutex):
(WTF::functionQueue):
(WTF::dispatchFunctionsFromMainThread):
(WTF::callOnMainThread):
(WTF::cancelCallOnMainThread):
* wtf/StackStats.cpp:
(WTF::StackStats::initialize):
(WTF::StackStats::CheckPoint::CheckPoint):
(WTF::StackStats::CheckPoint::~CheckPoint):
(WTF::StackStats::probe):
(WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
(WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint):
* wtf/StackStats.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162935
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-01-28 Anders Carlsson <andersca@apple.com>
+
+ Use std::mutex instead of WTF::Mutex in WTF
+ https://bugs.webkit.org/show_bug.cgi?id=127783
+
+ Reviewed by Antti Koivisto.
+
+ * wtf/CryptographicallyRandomNumber.cpp:
+ * wtf/MainThread.cpp:
+ (WTF::mainThreadFunctionQueueMutex):
+ (WTF::functionQueue):
+ (WTF::dispatchFunctionsFromMainThread):
+ (WTF::callOnMainThread):
+ (WTF::cancelCallOnMainThread):
+ * wtf/StackStats.cpp:
+ (WTF::StackStats::initialize):
+ (WTF::StackStats::CheckPoint::CheckPoint):
+ (WTF::StackStats::CheckPoint::~CheckPoint):
+ (WTF::StackStats::probe):
+ (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
+ (WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint):
+ * wtf/StackStats.h:
+
2014-01-27 Joseph Pecoraro <pecoraro@apple.com>
WebCore: Enable -Wimplicit-fallthrough and add FALLTHROUGH annotation where needed
#include "NeverDestroyed.h"
#include "OSRandomSource.h"
-#include "ThreadingPrimitives.h"
+#include <mutex>
namespace WTF {
ARC4Stream m_stream;
int m_count;
- Mutex m_mutex;
+ std::mutex m_mutex;
};
ARC4Stream::ARC4Stream()
uint32_t ARC4RandomNumberGenerator::randomNumber()
{
- MutexLocker locker(m_mutex);
+ std::lock_guard<std::mutex> lock(m_mutex);
m_count -= 4;
stirIfNeeded();
void ARC4RandomNumberGenerator::randomValues(void* buffer, size_t length)
{
- MutexLocker locker(m_mutex);
+ std::lock_guard<std::mutex> lock(m_mutex);
unsigned char* result = reinterpret_cast<unsigned char*>(buffer);
stirIfNeeded();
#include "Deque.h"
#include "Functional.h"
#include "StdLibExtras.h"
-#include "Threading.h"
+#include <mutex>
+#include <wtf/NeverDestroyed.h>
#include <wtf/ThreadSpecific.h>
namespace WTF {
static ThreadIdentifier mainThreadIdentifier;
#endif
-static Mutex& mainThreadFunctionQueueMutex()
+static std::mutex& mainThreadFunctionQueueMutex()
{
- DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
- return staticMutex;
+ static NeverDestroyed<std::mutex> mutex;
+
+ return mutex;
}
static FunctionQueue& functionQueue()
{
- DEFINE_STATIC_LOCAL(FunctionQueue, staticFunctionQueue, ());
- return staticFunctionQueue;
+ static NeverDestroyed<FunctionQueue> functionQueue;
+ return functionQueue;
}
FunctionWithContext invocation;
while (true) {
{
- MutexLocker locker(mainThreadFunctionQueueMutex());
+ std::lock_guard<std::mutex> lock(mainThreadFunctionQueueMutex());
if (!functionQueue().size())
break;
invocation = functionQueue().takeFirst();
ASSERT(function);
bool needToSchedule = false;
{
- MutexLocker locker(mainThreadFunctionQueueMutex());
+ std::lock_guard<std::mutex> lock(mainThreadFunctionQueueMutex());
needToSchedule = functionQueue().size() == 0;
functionQueue().append(FunctionWithContext(function, context));
}
{
ASSERT(function);
- MutexLocker locker(mainThreadFunctionQueueMutex());
+ std::lock_guard<std::mutex> lock(mainThreadFunctionQueueMutex());
FunctionWithContextFinder pred(FunctionWithContext(function, context));
// checkpoint. By default, we only log checkpoints that establish new
// max values.
-// #define ENABLE_VERBOSE_STACK_STATS 1
+#define ENABLE_VERBOSE_STACK_STATS 1
namespace WTF {
// CheckPoint management:
-Mutex* StackStats::s_sharedLock = 0;
+std::mutex* StackStats::s_sharedMutex = 0;
StackStats::CheckPoint* StackStats::s_topCheckPoint = 0;
StackStats::LayoutCheckPoint* StackStats::s_firstLayoutCheckPoint = 0;
StackStats::LayoutCheckPoint* StackStats::s_topLayoutCheckPoint = 0;
// Initializes locks and the log. Should only be called once.
void StackStats::initialize()
{
- s_sharedLock = new Mutex();
+ s_sharedMutex = std::make_unique<std::mutex>().release();
dataLogF(" === LOG new stack stats ========\n");
}
StackStats::CheckPoint::CheckPoint()
{
- MutexLocker locker(*StackStats::s_sharedLock);
+ std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
StackStats::PerThreadStats& t = threadData->stackStats();
const StackBounds& stack = threadData->stack();
StackStats::CheckPoint::~CheckPoint()
{
- MutexLocker locker(*StackStats::s_sharedLock);
+ std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
StackStats::PerThreadStats& t = threadData->stackStats();
void StackStats::probe()
{
- MutexLocker locker(*StackStats::s_sharedLock);
+ std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
StackStats::PerThreadStats& t = threadData->stackStats();
const StackBounds& stack = threadData->stack();
// probe first, we can avoid re-entering the lock.
StackStats::probe();
- MutexLocker locker(*StackStats::s_sharedLock);
+ std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
StackStats::PerThreadStats& t = threadData->stackStats();
const StackBounds& stack = threadData->stack();
StackStats::LayoutCheckPoint::~LayoutCheckPoint()
{
- MutexLocker locker(*StackStats::s_sharedLock);
+ std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
// Pop to the previous layout checkpoint:
StackStats::s_topLayoutCheckPoint = m_prev;
#define StackStats_h
#include "ExportMacros.h"
-#include "ThreadingPrimitives.h"
+#include <mutex>
// Define this flag to enable Stack stats collection. This feature is useful
// convenience for collecting that data. It is not meant to be enabled by
// default on release or debug builds.
-// #define ENABLE_STACK_STATS 1
+#define ENABLE_STACK_STATS 1
namespace WTF {
private:
// CheckPoint management:
- static Mutex* s_sharedLock;
+ static std::mutex* s_sharedMutex;
static CheckPoint* s_topCheckPoint;
static LayoutCheckPoint* s_firstLayoutCheckPoint;
static LayoutCheckPoint* s_topLayoutCheckPoint;