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


C++ boost::thread_specific_ptr类代码示例

本文整理汇总了C++中boost::thread_specific_ptr的典型用法代码示例。如果您正苦于以下问题:C++ thread_specific_ptr类的具体用法?C++ thread_specific_ptr怎么用?C++ thread_specific_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: toBigEndian

ldb::Slice dev::eth::toSlice(uint64_t _n, unsigned _sub)
{
#if ALL_COMPILERS_ARE_CPP11_COMPLIANT
	static thread_local FixedHash<33> h;
	toBigEndian(_n, bytesRef(h.data() + 24, 8));
	h[32] = (uint8_t)_sub;
	return (ldb::Slice)h.ref();
#else
	static boost::thread_specific_ptr<FixedHash<33>> t_h;
	if (!t_h.get())
		t_h.reset(new FixedHash<33>);
	bytesRef ref(t_h->data() + 24, 8);
	toBigEndian(_n, ref);
	(*t_h)[32] = (uint8_t)_sub;
	return (ldb::Slice)t_h->ref();
#endif
}
开发者ID:dan-da,项目名称:cpp-ethereum,代码行数:17,代码来源:BlockChain.cpp

示例2: LogAcceptCategory

bool LogAcceptCategory(const char* category)
{
    if (category != NULL) {
        if (!fDebug)
            return false;

        static boost::thread_specific_ptr<set<string> > ptrCategory;
        if (ptrCategory.get() == NULL) {
            const vector<string>& categories = mapMultiArgs["-debug"];
            ptrCategory.reset(new set<string>(categories.begin(), categories.end()));
        }
        const set<string>& setCategories = *ptrCategory.get();

        if (setCategories.count(string("")) == 0 && setCategories.count(string("1")) == 0 && setCategories.count(string(category)) == 0)
            return false;
    }
    return true;
}
开发者ID:Gulden,项目名称:gulden-official,代码行数:18,代码来源:util.cpp

示例3: getCurrentThreadAnalyzerWithSynonyms

Analyzer* AnalyzerFactory::getCurrentThreadAnalyzerWithSynonyms(const CoreInfo_t* config) {

    static boost::thread_specific_ptr<Analyzer> _tsAnalyzerObjectWithSynonyms;
    if (_tsAnalyzerObjectWithSynonyms.get() == NULL)
    {
        Logger::debug("Create Analyzer object for thread = %d ",  pthread_self());
        _tsAnalyzerObjectWithSynonyms.reset(AnalyzerFactory::createAnalyzer(config, false));
    }

    Analyzer* analyzer = _tsAnalyzerObjectWithSynonyms.get();

    // clear the initial states of the filters in the analyzer, e.g.,
    // for those filters that have an internal buffer to keep tokens.
    // Such an internal buffer can have leftover tokens from
    // the previous query (possibly an invalid query)
    analyzer->clearFilterStates();

    return analyzer;
}
开发者ID:SRCH2,项目名称:srch2-ngn,代码行数:19,代码来源:AnalyzerFactory.cpp

示例4: string

void M6Processor::ProcessFile(const string& inFileName, istream& inFileStream)
{
    mFileName.reset(new string(inFileName));

    io::filtering_stream<io::input> in;

    if (mConfig->find_first("filter"))
        in.push(M6Process(mConfig->find_first("filter")->content(), inFileStream));
    else
        in.push(inFileStream);

    try
    {
        if (mParser != nullptr)
            ParseFile(inFileName, in);
        else
            ParseXML(inFileName, in);
    }
    catch (exception& e)
    {
        cerr << endl
             << "Error parsing file " << inFileName << endl
             << e.what() << endl;
        Error(current_exception());
    }
}
开发者ID:cmbi,项目名称:mrs,代码行数:26,代码来源:M6Builder.cpp

示例5:

const CGHeroInstance * HeroPtr::get(bool doWeExpectNull /*= false*/) const
{
	//TODO? check if these all assertions every time we get info about hero affect efficiency
	//
	//behave terribly when attempting unauthorized access to hero that is not ours (or was lost)
	assert(doWeExpectNull || h);

	if(h)
	{
		auto obj = cb->getObj(hid);
		const bool owned = obj && obj->tempOwner == ai->playerID;

		if(doWeExpectNull && !owned)
		{
			return nullptr;
		}
		else
		{
			assert(obj);
			assert(owned);
		}
	}

	return h;
}
开发者ID:COJIDAT,项目名称:vcmi-ios,代码行数:25,代码来源:AIUtility.cpp

示例6: run

 bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
     nonce *n = new nonce(security.getNonce());
     stringstream ss;
     ss << hex << *n;
     result.append("nonce", ss.str() );
     lastNonce.reset(n);
     return true;
 }
开发者ID:alexdong,项目名称:mongo,代码行数:8,代码来源:security_commands.cpp

示例7: run

        bool run(const char *cmdns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
            string ns = cmdObj["getShardVersion"].valuestrsafe();
            if ( ns.size() == 0 ){
                errmsg = "need to speciy fully namespace";
                return false;
            }
            
            result.append( "configServer" , shardConfigServer.c_str() );

            result.appendTimestamp( "global" , globalVersions[ns] );
            if ( clientShardVersions.get() )
                result.appendTimestamp( "mine" , (*clientShardVersions.get())[ns] );
            else 
                result.appendTimestamp( "mine" , 0 );
            
            return true;
        }
开发者ID:whachoe,项目名称:mongo,代码行数:17,代码来源:d_logic.cpp

示例8: curopWaitingForLock

 void curopWaitingForLock( int type ){
     Client * c = currentClient.get();
     assert( c );
     CurOp * co = c->curop();
     if ( co ){
         co->waitingForLock( type );
     }
 }
开发者ID:kapouer,项目名称:mongo-debian,代码行数:8,代码来源:client.cpp

示例9: curopGotLock

 void curopGotLock(){
     Client * c = currentClient.get();
     assert(c);
     CurOp * co = c->curop();
     if ( co ){
         co->gotLock();
     }
 }
开发者ID:kapouer,项目名称:mongo-debian,代码行数:8,代码来源:client.cpp

示例10: handlePossibleShardedMessage

    bool handlePossibleShardedMessage( Message &m, DbResponse &dbresponse ){

        if ( shardConfigServer.empty() ){
            return false;
        }

        int op = m.data->operation();
        if ( op < 2000 || op >= 3000 )
            return false;

        
        const char *ns = m.data->_data + 4;
        string errmsg;
        if ( shardVersionOk( ns , errmsg ) ){
            return false;
        }

        log() << "shardVersionOk failed  ns:" << ns << " " << errmsg << endl;
        
        if ( doesOpGetAResponse( op ) ){
            BufBuilder b( 32768 );
            b.skip( sizeof( QueryResult ) );
            {
                BSONObj obj = BSON( "$err" << errmsg );
                b.append( obj.objdata() , obj.objsize() );
            }
            
            QueryResult *qr = (QueryResult*)b.buf();
            qr->_resultFlags() = QueryResult::ResultFlag_ErrSet | QueryResult::ResultFlag_ShardConfigStale;
            qr->len = b.len();
            qr->setOperation( opReply );
            qr->cursorId = 0;
            qr->startingFrom = 0;
            qr->nReturned = 1;
            b.decouple();

            Message * resp = new Message();
            resp->setData( qr , true );
            
            dbresponse.response = resp;
            dbresponse.responseTo = m.data->id;
            return true;
        }
        
        OID * clientID = clientServerIds.get();
        massert( 10422 ,  "write with bad shard config and no server id!" , clientID );
        
        log() << "got write with an old config - writing back" << endl;

        BSONObjBuilder b;
        b.appendBool( "writeBack" , true );
        b.append( "ns" , ns );
        b.appendBinData( "msg" , m.data->len , bdtCustom , (char*)(m.data) );
        log() << "writing back msg with len: " << m.data->len << " op: " << m.data->_operation << endl;
        clientQueues[clientID->str()]->push( b.obj() );

        return true;
    }
开发者ID:whachoe,项目名称:mongo,代码行数:58,代码来源:d_logic.cpp

示例11: foreach_neighbour

void foreach_neighbour(const int3 &pos, std::function<void(const int3& pos)> foo)
{
	for(const int3 &dir : dirs)
	{
		const int3 n = pos + dir;
		if(cb->isInTheMap(n))
			foo(pos+dir);
	}
}
开发者ID:janisozaur,项目名称:vcmi_old_mirror,代码行数:9,代码来源:AIUtility.cpp

示例12: howManyTilesWillBeDiscovered

int howManyTilesWillBeDiscovered(const int3 &pos, int radious)
{ //TODO: do not explore dead-end boundaries
	int ret = 0;
	for(int x = pos.x - radious; x <= pos.x + radious; x++)
	{
		for(int y = pos.y - radious; y <= pos.y + radious; y++)
		{
			int3 npos = int3(x,y,pos.z);
			if(cb->isInTheMap(npos) && pos.dist2d(npos) - 0.5 < radious  && !cb->isVisible(npos))
			{
				if (!boundaryBetweenTwoPoints (pos, npos))
					ret++;
			}
		}
	}

	return ret;
}
开发者ID:janisozaur,项目名称:vcmi_old_mirror,代码行数:18,代码来源:AIUtility.cpp

示例13: check

	void condition_variable_recursive_mutex::check(xrecursive_mutex& mtx)
	{
		if (mtx.pri_level != xrecursive_mutex::NOCARE_PRIMARY_LEVEL)
		{
			quick_int_stack* pri_levels = locks_hold_by_current_thread.get();
			XASSERT((pri_levels != NULL) && (!pri_levels->empty()) &&
				(pri_levels->top() == mtx.pri_level));
		}
	}
开发者ID:wanganran,项目名称:TCP-UDP-Proxy,代码行数:9,代码来源:xthread.cpp

示例14: whatToDoToAchieve

TSubgoal GetObj::whatToDoToAchieve()
{
	const CGObjectInstance * obj = cb->getObj(ObjectInstanceID(objid));
	if(!obj)
		return sptr (Goals::Explore());
	int3 pos = obj->visitablePos();
	if (hero)
	{
		if (ai->isAccessibleForHero(pos, hero))
			return sptr (Goals::VisitTile(pos).sethero(hero));
	}
	else
	{
		if (isReachable(obj))
			return sptr (Goals::VisitTile(pos).sethero(hero)); //we must visit object with same hero, if any
	}
	return sptr (Goals::ClearWayTo(pos).sethero(hero));
}
开发者ID:szpak,项目名称:vcmi,代码行数:18,代码来源:Goals.cpp

示例15: IsWorkerThread

/**
 * Checks whether the calling thread is one of the worker threads
 * for this work queue.
 *
 * @returns true if called from one of the worker threads, false otherwise
 */
bool WorkQueue::IsWorkerThread(void) const
{
	WorkQueue **pwq = l_ThreadWorkQueue.get();

	if (!pwq)
		return false;

	return *pwq == this;
}
开发者ID:wzhsunn,项目名称:icinga2,代码行数:15,代码来源:workqueue.cpp


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