pollymc/logic/net/NetWorker.cpp

31 lines
486 B
C++
Raw Normal View History

#include "NetWorker.h"
#include <QThreadStorage>
2013-09-02 03:55:40 +05:30
class NetWorker::Private
{
public:
QNetworkAccessManager manager;
};
NetWorker::NetWorker ( QObject* parent ) : QObject ( parent )
{
d = new Private();
}
QNetworkAccessManager& NetWorker::qnam()
{
auto & w = worker();
return w.d->manager;
}
NetWorker& NetWorker::worker()
{
static QThreadStorage<NetWorker *> storage;
if (!storage.hasLocalData())
{
storage.setLocalData(new NetWorker());
}
return *storage.localData();
}