Switching to xe::mutex.

This commit is contained in:
Ben Vanik
2015-05-24 23:16:43 -07:00
parent 814ec82ad4
commit f5a2b85d42
31 changed files with 133 additions and 108 deletions

View File

@@ -81,7 +81,7 @@ X_RESULT XXMPApp::XMPCreateTitlePlaylist(
xe::store_and_swap<uint32_t>(memory_->TranslateVirtual(out_playlist_handle),
playlist->handle);
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<xe::mutex> lock(mutex_);
playlists_.insert({playlist->handle, playlist.get()});
playlist.release();
return X_ERROR_SUCCESS;
@@ -89,7 +89,7 @@ X_RESULT XXMPApp::XMPCreateTitlePlaylist(
X_RESULT XXMPApp::XMPDeleteTitlePlaylist(uint32_t playlist_handle) {
XELOGD("XMPDeleteTitlePlaylist(%.8X)", playlist_handle);
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<xe::mutex> lock(mutex_);
auto it = playlists_.find(playlist_handle);
if (it == playlists_.end()) {
XELOGE("Playlist %.8X not found", playlist_handle);
@@ -109,7 +109,7 @@ X_RESULT XXMPApp::XMPPlayTitlePlaylist(uint32_t playlist_handle,
XELOGD("XMPPlayTitlePlaylist(%.8X, %.8X)", playlist_handle, song_handle);
Playlist* playlist = nullptr;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<xe::mutex> lock(mutex_);
auto it = playlists_.find(playlist_handle);
if (it == playlists_.end()) {
XELOGE("Playlist %.8X not found", playlist_handle);

View File

@@ -16,6 +16,7 @@
#include <unordered_map>
#include <vector>
#include "xenia/base/mutex.h"
#include "xenia/kernel/app.h"
#include "xenia/kernel/kernel_state.h"
@@ -101,7 +102,7 @@ class XXMPApp : public XApp {
Playlist* active_playlist_;
int active_song_index_;
std::mutex mutex_;
xe::mutex mutex_;
std::unordered_map<uint32_t, Playlist*> playlists_;
uint32_t next_playlist_handle_;
uint32_t next_song_handle_;

View File

@@ -120,7 +120,7 @@ std::unique_ptr<ContentPackage> ContentManager::ResolvePackage(
return nullptr;
}
std::lock_guard<std::recursive_mutex> lock(content_mutex_);
std::lock_guard<xe::recursive_mutex> lock(content_mutex_);
auto package = std::make_unique<ContentPackage>(kernel_state_, root_name,
data, package_path);
@@ -134,7 +134,7 @@ bool ContentManager::ContentExists(const XCONTENT_DATA& data) {
X_RESULT ContentManager::CreateContent(std::string root_name,
const XCONTENT_DATA& data) {
std::lock_guard<std::recursive_mutex> lock(content_mutex_);
std::lock_guard<xe::recursive_mutex> lock(content_mutex_);
if (open_packages_.count(root_name)) {
// Already content open with this root name.
@@ -161,7 +161,7 @@ X_RESULT ContentManager::CreateContent(std::string root_name,
X_RESULT ContentManager::OpenContent(std::string root_name,
const XCONTENT_DATA& data) {
std::lock_guard<std::recursive_mutex> lock(content_mutex_);
std::lock_guard<xe::recursive_mutex> lock(content_mutex_);
if (open_packages_.count(root_name)) {
// Already content open with this root name.
@@ -184,7 +184,7 @@ X_RESULT ContentManager::OpenContent(std::string root_name,
}
X_RESULT ContentManager::CloseContent(std::string root_name) {
std::lock_guard<std::recursive_mutex> lock(content_mutex_);
std::lock_guard<xe::recursive_mutex> lock(content_mutex_);
auto it = open_packages_.find(root_name);
if (it == open_packages_.end()) {
@@ -200,7 +200,7 @@ X_RESULT ContentManager::CloseContent(std::string root_name) {
X_RESULT ContentManager::GetContentThumbnail(const XCONTENT_DATA& data,
std::vector<uint8_t>* buffer) {
std::lock_guard<std::recursive_mutex> lock(content_mutex_);
std::lock_guard<xe::recursive_mutex> lock(content_mutex_);
auto package_path = ResolvePackagePath(data);
auto thumb_path = xe::join_paths(package_path, kThumbnailFileName);
if (xe::fs::PathExists(thumb_path)) {
@@ -219,7 +219,7 @@ X_RESULT ContentManager::GetContentThumbnail(const XCONTENT_DATA& data,
X_RESULT ContentManager::SetContentThumbnail(const XCONTENT_DATA& data,
std::vector<uint8_t> buffer) {
std::lock_guard<std::recursive_mutex> lock(content_mutex_);
std::lock_guard<xe::recursive_mutex> lock(content_mutex_);
auto package_path = ResolvePackagePath(data);
if (xe::fs::PathExists(package_path)) {
auto thumb_path = xe::join_paths(package_path, kThumbnailFileName);
@@ -233,7 +233,7 @@ X_RESULT ContentManager::SetContentThumbnail(const XCONTENT_DATA& data,
}
X_RESULT ContentManager::DeleteContent(const XCONTENT_DATA& data) {
std::lock_guard<std::recursive_mutex> lock(content_mutex_);
std::lock_guard<xe::recursive_mutex> lock(content_mutex_);
auto package_path = ResolvePackagePath(data);
if (xe::fs::PathExists(package_path)) {

View File

@@ -17,6 +17,7 @@
#include <vector>
#include "xenia/base/memory.h"
#include "xenia/base/mutex.h"
#include "xenia/xbox.h"
namespace xe {
@@ -87,7 +88,7 @@ class ContentManager {
KernelState* kernel_state_;
std::wstring root_path_;
std::recursive_mutex content_mutex_;
xe::recursive_mutex content_mutex_;
std::unordered_map<std::string, ContentPackage*> open_packages_;
};

View File

@@ -12,6 +12,7 @@
#include <mutex>
#include "xenia/base/mutex.h"
#include "xenia/xbox.h"
namespace xe {
@@ -36,7 +37,7 @@ class Dispatcher {
private:
KernelState* kernel_state_;
std::mutex lock_;
xe::mutex lock_;
NativeList* dpc_list_;
};

View File

@@ -42,7 +42,7 @@ void XNotifyListener::EnqueueNotification(XNotificationID id, uint32_t data) {
return;
}
std::lock_guard<std::mutex> lock(lock_);
std::lock_guard<xe::mutex> lock(lock_);
if (notifications_.count(id)) {
// Already exists. Overwrite.
notifications_[id] = data;
@@ -56,7 +56,7 @@ void XNotifyListener::EnqueueNotification(XNotificationID id, uint32_t data) {
bool XNotifyListener::DequeueNotification(XNotificationID* out_id,
uint32_t* out_data) {
std::lock_guard<std::mutex> lock(lock_);
std::lock_guard<xe::mutex> lock(lock_);
bool dequeued = false;
if (notification_count_) {
dequeued = true;
@@ -74,7 +74,7 @@ bool XNotifyListener::DequeueNotification(XNotificationID* out_id,
bool XNotifyListener::DequeueNotification(XNotificationID id,
uint32_t* out_data) {
std::lock_guard<std::mutex> lock(lock_);
std::lock_guard<xe::mutex> lock(lock_);
bool dequeued = false;
if (notification_count_) {
dequeued = true;

View File

@@ -13,6 +13,7 @@
#include <mutex>
#include <unordered_map>
#include "xenia/base/mutex.h"
#include "xenia/kernel/xobject.h"
#include "xenia/xbox.h"
@@ -36,7 +37,7 @@ class XNotifyListener : public XObject {
private:
HANDLE wait_handle_;
std::mutex lock_;
xe::mutex lock_;
std::unordered_map<XNotificationID, uint32_t> notifications_;
size_t notification_count_;
uint64_t mask_;

View File

@@ -13,6 +13,7 @@
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/base/mutex.h"
#include "xenia/base/threading.h"
#include "xenia/cpu/cpu.h"
#include "xenia/kernel/kernel_state.h"
@@ -33,7 +34,7 @@ using namespace xe::cpu;
uint32_t next_xthread_id = 0;
thread_local XThread* current_thread_tls;
std::mutex critical_region_;
xe::mutex critical_region_;
XThread* shared_kernel_thread_ = 0;
XThread::XThread(KernelState* kernel_state, uint32_t stack_size,

View File

@@ -97,7 +97,7 @@ class XThread : public XObject {
std::string name_;
std::atomic<uint32_t> irql_;
std::mutex apc_lock_;
xe::mutex apc_lock_;
NativeList* apc_list_;
object_ref<XEvent> event_;

View File

@@ -150,6 +150,7 @@ SHIM_CALL NtDuplicateObject_shim(PPCContext* ppc_state, KernelState* state) {
auto object = state->object_table()->LookupObject<XObject>(handle);
if (object) {
object->Retain();
object->RetainHandle();
uint32_t new_handle = object->handle();
if (new_handle_ptr) {

View File

@@ -9,6 +9,7 @@
#include "xenia/base/atomic.h"
#include "xenia/base/logging.h"
#include "xenia/base/mutex.h"
#include "xenia/cpu/processor.h"
#include "xenia/kernel/dispatcher.h"
#include "xenia/kernel/kernel_state.h"
@@ -1290,7 +1291,7 @@ SHIM_CALL KeRemoveQueueDpc_shim(PPCContext* ppc_state, KernelState* state) {
SHIM_SET_RETURN_64(result ? 1 : 0);
}
std::mutex global_list_mutex_;
xe::mutex global_list_mutex_;
// http://www.nirsoft.net/kernel_struct/vista/SLIST_HEADER.html
SHIM_CALL InterlockedPopEntrySList_shim(PPCContext* ppc_state,
@@ -1299,7 +1300,7 @@ SHIM_CALL InterlockedPopEntrySList_shim(PPCContext* ppc_state,
XELOGD("InterlockedPopEntrySList(%.8X)", plist_ptr);
std::lock_guard<std::mutex> lock(global_list_mutex_);
std::lock_guard<xe::mutex> lock(global_list_mutex_);
uint8_t* p = state->memory()->TranslateVirtual(plist_ptr);
auto first = xe::load_and_swap<uint32_t>(p);