2014-01-20 01:57:00 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2017-01-25 12:36:41 +00:00
|
|
|
#include "mozilla/Assertions.h"
|
2014-01-20 01:57:00 +00:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2017-02-09 01:52:55 +00:00
|
|
|
#include "mozilla/PlatformMutex.h"
|
2014-01-20 01:57:00 +00:00
|
|
|
|
2017-02-09 01:52:55 +00:00
|
|
|
#include <windows.h>
|
2014-01-20 01:57:00 +00:00
|
|
|
|
2017-02-09 01:52:55 +00:00
|
|
|
#include "MutexPlatformData_windows.h"
|
2014-01-20 01:57:00 +00:00
|
|
|
|
2017-02-09 01:52:55 +00:00
|
|
|
mozilla::detail::MutexImpl::MutexImpl()
|
2014-01-20 01:57:00 +00:00
|
|
|
{
|
2018-04-23 17:45:20 +00:00
|
|
|
InitializeSRWLock(&platformData()->lock);
|
2014-01-20 01:57:00 +00:00
|
|
|
}
|
|
|
|
|
2017-02-09 01:52:55 +00:00
|
|
|
mozilla::detail::MutexImpl::~MutexImpl()
|
2014-01-20 01:57:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-02-09 01:52:55 +00:00
|
|
|
mozilla::detail::MutexImpl::lock()
|
2014-01-20 01:57:00 +00:00
|
|
|
{
|
2018-04-23 17:45:20 +00:00
|
|
|
AcquireSRWLockExclusive(&platformData()->lock);
|
2014-01-20 01:57:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-02-09 01:52:55 +00:00
|
|
|
mozilla::detail::MutexImpl::unlock()
|
2014-01-20 01:57:00 +00:00
|
|
|
{
|
2018-04-23 17:45:20 +00:00
|
|
|
ReleaseSRWLockExclusive(&platformData()->lock);
|
2014-01-20 01:57:00 +00:00
|
|
|
}
|
2017-01-25 12:36:41 +00:00
|
|
|
|
2017-02-09 01:52:55 +00:00
|
|
|
mozilla::detail::MutexImpl::PlatformData*
|
|
|
|
mozilla::detail::MutexImpl::platformData()
|
2017-01-25 12:36:41 +00:00
|
|
|
{
|
|
|
|
static_assert(sizeof(platformData_) >= sizeof(PlatformData),
|
|
|
|
"platformData_ is too small");
|
|
|
|
return reinterpret_cast<PlatformData*>(platformData_);
|
|
|
|
}
|