当前位置: 首页>>代码示例>>C++>>正文


C++ QThreadStorage::hasLocalData方法代码示例

本文整理汇总了C++中QThreadStorage::hasLocalData方法的典型用法代码示例。如果您正苦于以下问题:C++ QThreadStorage::hasLocalData方法的具体用法?C++ QThreadStorage::hasLocalData怎么用?C++ QThreadStorage::hasLocalData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QThreadStorage的用法示例。


在下文中一共展示了QThreadStorage::hasLocalData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock

			QSharedPointer<RDFGraphCache> TrackerService::getRDFGraphCache(bool persistent)
			{
				QSharedPointer<RDFGraphCache> ret;
				if(!tracker_tls.hasLocalData()
					// check if the weak pointer in local data is valid and store it to ret
					|| !(ret = *tracker_tls.localData()))
				{
					static bool initialized = false;
					if(!initialized)
					{
						QMutexLocker lock(&tracker_global_lock_g);
						if(!initialized)
							initialized = initializeTrackerEnvironment();
					}

					QSharedPointer<TrackerService> tracker
							= QSharedCreator<TrackerService>::create();
					tracker->setParent( tracker.toWeakRef() );
					ret = QSharedCreator<RDFGraphCache>::create(tracker);
					tracker_tls.setLocalData(new QWeakPointer<RDFGraphCache>(ret));
				}
				if(persistent && !tracker_persistent_tls.hasLocalData())
					tracker_persistent_tls.setLocalData
							(new TLSDestroyer<QSharedPointer<RDFGraphCache> >(ret));
				return ret;
			}
开发者ID:dudochkin-victor,项目名称:libqttracker,代码行数:26,代码来源:tracker_p.cpp

示例2: hasLocalData

void tst_QThreadStorage::hasLocalData()
{
    QThreadStorage<Pointer *> pointers;
    QVERIFY(!pointers.hasLocalData());
    pointers.setLocalData(new Pointer);
    QVERIFY(pointers.hasLocalData());
    pointers.setLocalData(0);
    QVERIFY(!pointers.hasLocalData());
}
开发者ID:dewhisna,项目名称:emscripten-qt,代码行数:9,代码来源:tst_qthreadstorage.cpp

示例3: localData

void tst_QThreadStorage::localData()
{
    QThreadStorage<Pointer*> pointers;
    Pointer *p = new Pointer;
    QVERIFY(!pointers.hasLocalData());
    pointers.setLocalData(p);
    QVERIFY(pointers.hasLocalData());
    QCOMPARE(pointers.localData(), p);
    pointers.setLocalData(0);
    QCOMPARE(pointers.localData(), (Pointer *)0);
    QVERIFY(!pointers.hasLocalData());
}
开发者ID:dewhisna,项目名称:emscripten-qt,代码行数:12,代码来源:tst_qthreadstorage.cpp

示例4: getInstance

OAuthNetworkAccessManager* OAuthNetworkAccessManager::getInstance() {
    if (!oauthNetworkAccessManagers.hasLocalData()) {
        oauthNetworkAccessManagers.setLocalData(new OAuthNetworkAccessManager());
    }
    
    return oauthNetworkAccessManagers.localData();
}
开发者ID:cozza13,项目名称:hifi,代码行数:7,代码来源:OAuthNetworkAccessManager.cpp

示例5: IconvProcessor

IconvProcessor & ucs4ToUtf8()
{
	static QThreadStorage<IconvProcessor *> processor;
	if (!processor.hasLocalData())
		processor.setLocalData(new IconvProcessor("UTF-8", ucs4_codeset));
	return *processor.localData();
}
开发者ID:315234,项目名称:lyx-retina,代码行数:7,代码来源:unicode.cpp

示例6: trackerRelease

			RDFServicePtr trackerRelease()
			{
				if(!tracker_persistent_tls.hasLocalData())
					return RDFServicePtr();
				RDFServicePtr ret = *tracker_persistent_tls.localData();
				tracker_persistent_tls.setLocalData(0);
				return ret;
			}
开发者ID:dudochkin-victor,项目名称:libqttracker,代码行数:8,代码来源:tracker_p.cpp

示例7: removeFromCache

void removeFromCache(const QString &key)
//! [8] //! [9]
{
    if (!caches.hasLocalData())
        return;

    caches.localData().remove(key);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:8,代码来源:threads.cpp

示例8: cacheObject

void cacheObject(const QString &key, SomeClass *object)
//! [7] //! [8]
{
    if (!caches.hasLocalData())
        caches.setLocalData(new QCache<QString, SomeClass>);

    caches.localData()->insert(key, object);
}
开发者ID:BadSingleton,项目名称:pyside2,代码行数:8,代码来源:threads.cpp

示例9: defer

void defer(const VoidFunc & function)
{
    // create a helper in this thread if not yet created
    if( ! deferHelpers.hasLocalData()) {
        deferHelpers.setLocalData( new DeferHelper);
    }

    // queue up the function execution in this same thread
    // (because the object was created in this same thread)
    deferHelpers.localData()-> queue( function);
}
开发者ID:astrilet,项目名称:CARTAvis,代码行数:11,代码来源:MyQApp.cpp

示例10: nCmp

bool Utils::String::naturalCompareCaseInsensitive(const QString &left, const QString &right)
{
    // provide a single `NaturalCompare` instance for easy use
    // https://doc.qt.io/qt-5/threads-reentrancy.html
#ifdef Q_OS_MAC  // workaround for Apple xcode: https://stackoverflow.com/a/29929949
    static QThreadStorage<NaturalCompare> nCmp;
    if (!nCmp.hasLocalData()) nCmp.setLocalData(NaturalCompare(false));
    return (nCmp.localData())(left, right);
#else
    thread_local NaturalCompare nCmp(false);
    return nCmp(left, right);
#endif
}
开发者ID:0ly,项目名称:qBittorrent,代码行数:13,代码来源:string.cpp

示例11: getThreadString

/** Return the string used to identify a particular thread */
QString SIREERROR_EXPORT getThreadString()
{
    QThreadStorage<QString*> *store = pidStrings();

    if (store->hasLocalData())
    {
        return *(store->localData());
    }
    else
    {
        return QString::null;
    }
}
开发者ID:Alwnikrotikz,项目名称:sire,代码行数:14,代码来源:exception.cpp

示例12: processor

vector<char_type>
eightbit_to_ucs4(char const * s, size_t ls, string const & encoding)
{
	static QThreadStorage<map<string, IconvProcessor> *> static_processors;
	if (!static_processors.hasLocalData())
		static_processors.setLocalData(new map<string, IconvProcessor>);
	map<string, IconvProcessor> & processors = *static_processors.localData();
	if (processors.find(encoding) == processors.end()) {
		IconvProcessor processor(ucs4_codeset, encoding.c_str());
		processors.insert(make_pair(encoding, processor));
	}
	return iconv_convert<char_type>(processors[encoding], s, ls);
}
开发者ID:315234,项目名称:lyx-retina,代码行数:13,代码来源:unicode.cpp

示例13: testAdoptedThreadStorageWin

void testAdoptedThreadStorageWin(void *p)
{
    QThreadStorage<Pointer *>  *pointers = reinterpret_cast<QThreadStorage<Pointer *> *>(p);
    if (pointers->hasLocalData()) {
        threadStorageOk = false;
        return;
    }

    Pointer *pointer = new Pointer();
    pointers->setLocalData(pointer);

    if (pointers->hasLocalData() == false) {
        threadStorageOk = false;
        return;
    }

    if (pointers->localData() != pointer) {
        threadStorageOk = false;
        return;
    }
    QObject::connect(QThread::currentThread(), SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
}
开发者ID:dewhisna,项目名称:emscripten-qt,代码行数:22,代码来源:tst_qthreadstorage.cpp

示例14: getPIDString

/** Return the string used by SireError to identify a particular
    thread within a process */
QString SIREERROR_EXPORT getPIDString()
{
    QThreadStorage<QString*> *store = pidStrings();

    if (store->hasLocalData())
    {
        return QString("%1:%2").arg( getProcessString(),
                                     *(store->localData()) );
    }
    else
    {
        return getProcessString();
    }
}
开发者ID:Alwnikrotikz,项目名称:sire,代码行数:16,代码来源:exception.cpp

示例15: connIdMsgHandler

void RpcConnection::connIdMsgHandler(QtMsgType /*type*/, const char* msg)
{
    if (connId.hasLocalData()) {
        QString newMsg(*connId.localData());
        newMsg.append(msg);
        newMsg.replace(QChar('\n'), QString("\n").append(*connId.localData()));
        fprintf(stderr, "%s\n", qPrintable(newMsg));
        fflush(stderr);
        return;
    }

    fprintf(stderr, "%s\n", msg);
    fflush(stderr);
}
开发者ID:anju61188,项目名称:ostinato,代码行数:14,代码来源:rpcconn.cpp


注:本文中的QThreadStorage::hasLocalData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。