PrismLauncher/logic/net/NetWorker.cpp

31 lines
486 B
C++
Raw Normal View History

#include "NetWorker.h"
#include <QThreadStorage>
2013-09-01 23:25:40 +01:00
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();
}