summaryrefslogtreecommitdiffstats
path: root/logic/net/NetWorker.cpp
blob: c5943348cb4d3d188075b4bee79698d8284b7954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "NetWorker.h"
#include <QThreadStorage>

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();
}