mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-06 04:33:49 +01:00
Remove experimental unused stuff.
This commit is contained in:
1 parent
06663c478d
commit
0f6a90098b
4 files changed
+1
-92
No files matched your search
@@ -63,58 +63,3 @@ struct Mailbox {
|
||||
private:
|
||||
std::atomic<int> refcount_;
|
||||
};
|
||||
|
||||
|
||||
// POD so can be moved around freely.
|
||||
// TODO: I can't quite get this to work with all the moves, the refcount blows up. I'll just use mailboxes directly.
|
||||
|
||||
/*
|
||||
template<class T>
|
||||
class Rx {
|
||||
public:
|
||||
Rx() : mbx_(nullptr) {}
|
||||
Rx(Mailbox<T> *mbx) : mbx_(mbx) { mbx_->AddRef(); }
|
||||
Rx(Rx<T> &&rx) { mbx_ = rx.mbx_; }
|
||||
Rx<T>& operator=(Rx<T> &&rx) { mbx_ = rx.mbx_; return *this; }
|
||||
~Rx() {
|
||||
mbx_->Release();
|
||||
}
|
||||
bool Poll(T **data) {
|
||||
return mbx_->Poll(data);
|
||||
}
|
||||
T *Wait() {
|
||||
return mbx_->Wait();
|
||||
}
|
||||
|
||||
private:
|
||||
Mailbox<T> *mbx_;
|
||||
};
|
||||
|
||||
// POD so can be moved around freely.
|
||||
template<class T>
|
||||
class Tx {
|
||||
public:
|
||||
Tx() : mbx_(nullptr) {}
|
||||
Tx(Mailbox<T> *mbx) : mbx_(mbx) { mbx_->AddRef(); }
|
||||
Tx(Tx<T> &&rx) { mbx_ = rx.mbx_; }
|
||||
Tx<T>& operator=(Tx<T> &&rx) { mbx_ = rx.mbx_; return *this; }
|
||||
|
||||
~Tx() {
|
||||
mbx_->Release();
|
||||
}
|
||||
bool Send(T *t) {
|
||||
return mbx_->Send(t);
|
||||
}
|
||||
|
||||
private:
|
||||
Mailbox<T> *mbx_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
std::pair<Rx<T>, Tx<T>> CreateChannel() {
|
||||
Mailbox<T> *mbx = new Mailbox<T>();
|
||||
auto retval = std::make_pair(Rx<T>(mbx), Tx<T>(mbx));
|
||||
mbx->Release();
|
||||
return retval;
|
||||
}
|
||||
*/
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/Thread/ThreadManager.h"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
@@ -44,12 +44,6 @@ public:
|
||||
mailbox->AddRef();
|
||||
return promise;
|
||||
}
|
||||
/*
|
||||
Promise(Promise &&promise) noexcept {
|
||||
data_ = promise.data_;
|
||||
ready_ = promise.ready_;
|
||||
rx_ = promise.rx_;
|
||||
}*/
|
||||
|
||||
~Promise() {
|
||||
if (rx_) {
|
||||
|
||||
@@ -2,37 +2,6 @@
|
||||
|
||||
#include <mutex>
|
||||
|
||||
// I plan to experiment with these to see if this approach can also work in C++.
|
||||
// The major advantage compared to a normal mutex is that we use the type system
|
||||
// to enforce that the resource is only accessed when the mutex is locked.
|
||||
|
||||
template<class T>
|
||||
class RustMutexProxy {
|
||||
public:
|
||||
RustMutexProxy(T *data, std::mutex &mutex) : data_(data), mutex_(mutex) {}
|
||||
~RustMutexProxy() { mutex_.unlock(); }
|
||||
T &operator*() { return *data_; }
|
||||
T *operator->() { return data_; }
|
||||
private:
|
||||
T *data_;
|
||||
std::mutex &mutex_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class RustMutex {
|
||||
public:
|
||||
RustMutex(T && t) : t_(t) {}
|
||||
|
||||
RustMutexProxy<T> lock() {
|
||||
mutex_.lock();
|
||||
return RustMutexProxy<T>(&t_, mutex_);
|
||||
}
|
||||
|
||||
private:
|
||||
T t_;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
|
||||
// Note that name must be a global string that lives until the end of the process,
|
||||
// for AssertCurrentThreadName to work.
|
||||
void SetCurrentThreadName(const char *threadName);
|
||||
|
||||
Reference in new issue
Block a user