2013-08-07 05:08:18 +05:30
|
|
|
#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()
|
2013-08-07 05:08:18 +05:30
|
|
|
{
|
|
|
|
static QThreadStorage<NetWorker *> storage;
|
|
|
|
if (!storage.hasLocalData())
|
|
|
|
{
|
|
|
|
storage.setLocalData(new NetWorker());
|
|
|
|
}
|
|
|
|
return *storage.localData();
|
|
|
|
}
|