mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 11:54:30 +01:00
Move C++11 functions to std namespace.
This commit is contained in:
1 parent
5ee92c352b
commit
0ef45bd23d
6 files changed
+18
-22
No files matched your search
+6
-10
@@ -10,7 +10,6 @@
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
using boost::shared_ptr;
|
||||
#else
|
||||
#include <memory>
|
||||
using std::shared_ptr;
|
||||
@@ -23,7 +22,11 @@ using std::shared_ptr;
|
||||
#include <tr1/memory>
|
||||
#endif
|
||||
namespace std {
|
||||
#ifndef __SYMBIAN32__
|
||||
#ifdef __SYMBIAN32__
|
||||
using boost::bind;
|
||||
using boost::function;
|
||||
using boost::shared_ptr;
|
||||
#else
|
||||
using tr1::bind;
|
||||
using tr1::function;
|
||||
using tr1::shared_ptr;
|
||||
@@ -40,21 +43,14 @@ namespace std {
|
||||
{
|
||||
return shared_ptr<T>(new T(arg1));
|
||||
}
|
||||
|
||||
#else
|
||||
using std::bind;
|
||||
using std::function;
|
||||
using std::shared_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#define placeholder
|
||||
#define p
|
||||
#elif defined(IOS)
|
||||
namespace placeholder = std::tr1::placeholders;
|
||||
namespace p = std::tr1::placeholders;
|
||||
#else
|
||||
namespace placeholder = std::placeholders;
|
||||
namespace p = std::placeholders;
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ int Client::POST(const char *resource, const std::string &data, Buffer *output)
|
||||
Download::Download(const std::string &url, const std::string &outfile)
|
||||
: url_(url), outfile_(outfile), progress_(0.0f), failed_(false) {
|
||||
|
||||
std::thread th(bind(&Download::Do, this));
|
||||
std::thread th(std::bind(&Download::Do, this));
|
||||
th.detach();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
///////////////////////////// WorkerThread
|
||||
|
||||
WorkerThread::WorkerThread() : active(true), started(false) {
|
||||
thread = new std::thread(bind(&WorkerThread::WorkFunc, this));
|
||||
thread = new std::thread(std::bind(&WorkerThread::WorkFunc, this));
|
||||
doneMutex.lock();
|
||||
while(!started) { };
|
||||
}
|
||||
@@ -17,7 +17,7 @@ WorkerThread::~WorkerThread() {
|
||||
delete thread;
|
||||
}
|
||||
|
||||
void WorkerThread::Process(const function<void()>& work) {
|
||||
void WorkerThread::Process(const std::function<void()>& work) {
|
||||
mutex.lock();
|
||||
work_ = work;
|
||||
signal.notify_one();
|
||||
@@ -56,7 +56,7 @@ void ThreadPool::StartWorkers() {
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadPool::ParallelLoop(function<void(int,int)> loop, int lower, int upper) {
|
||||
void ThreadPool::ParallelLoop(std::function<void(int,int)> loop, int lower, int upper) {
|
||||
mutex.lock();
|
||||
StartWorkers();
|
||||
int range = upper-lower;
|
||||
@@ -66,7 +66,7 @@ void ThreadPool::ParallelLoop(function<void(int,int)> loop, int lower, int upper
|
||||
int chunk = range/numThreads;
|
||||
int s = lower;
|
||||
for(int i=0; i<numThreads-1; ++i) {
|
||||
workers[i]->Process(bind(loop, s, s+chunk));
|
||||
workers[i]->Process(std::bind(loop, s, s+chunk));
|
||||
s+=chunk;
|
||||
}
|
||||
loop(s, upper);
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ public:
|
||||
~WorkerThread();
|
||||
|
||||
// submit a new work item
|
||||
void Process(const function<void()>& work);
|
||||
void Process(const std::function<void()>& work);
|
||||
// wait for a submitted work item to be completed
|
||||
void WaitForCompletion();
|
||||
|
||||
@@ -23,7 +23,7 @@ private:
|
||||
::condition_variable done; // used to signal work completion
|
||||
::recursive_mutex mutex, doneMutex; // associated with each respective condition variable
|
||||
volatile bool active, started;
|
||||
function<void()> work_; // the work to be done by this thread
|
||||
std::function<void()> work_; // the work to be done by this thread
|
||||
|
||||
void WorkFunc();
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
// don't need a destructor, "workers" is cleared on delete,
|
||||
// leading to the stopping and joining of all worker threads (RAII and all that)
|
||||
|
||||
void ParallelLoop(function<void(int,int)> loop, int lower, int upper);
|
||||
void ParallelLoop(std::function<void(int,int)> loop, int lower, int upper);
|
||||
|
||||
private:
|
||||
const int numThreads;
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ void MeasureBySpec(Size sz, float contentWidth, MeasureSpec spec, float *measure
|
||||
}
|
||||
}
|
||||
|
||||
void Event::Add(function<EventReturn(EventParams&)> func) {
|
||||
void Event::Add(std::function<EventReturn(EventParams&)> func) {
|
||||
HandlerRegistration reg;
|
||||
reg.func = func;
|
||||
handlers_.push_back(reg);
|
||||
|
||||
@@ -157,14 +157,14 @@ struct EventParams {
|
||||
};
|
||||
|
||||
struct HandlerRegistration {
|
||||
function<EventReturn(EventParams&)> func;
|
||||
std::function<EventReturn(EventParams&)> func;
|
||||
};
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event() : triggered_(false) {}
|
||||
|
||||
void Add(function<EventReturn(EventParams&)> func);
|
||||
void Add(std::function<EventReturn(EventParams&)> func);
|
||||
|
||||
// Call this from input thread or whatever, it doesn't matter
|
||||
void Trigger(EventParams &e);
|
||||
@@ -410,7 +410,7 @@ class CheckBox : public ClickableItem {
|
||||
public:
|
||||
CheckBox(bool *toggle, const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = 0)
|
||||
: ClickableItem(layoutParams), text_(text), smallText_(smallText) {
|
||||
OnClick.Add(bind(&CheckBox::OnClicked, this, placeholder::_1));
|
||||
OnClick.Add(std::bind(&CheckBox::OnClicked, this, placeholder::_1));
|
||||
}
|
||||
|
||||
virtual void Draw(UIContext &dc);
|
||||
|
||||
Reference in new issue
Block a user