1 2 3 4 5 6 7 8 9 10 11 12
#include "NetWorker.h" #include <QThreadStorage> NetWorker& NetWorker::spawn() { static QThreadStorage<NetWorker *> storage; if (!storage.hasLocalData()) { storage.setLocalData(new NetWorker()); } return *storage.localData(); }