本文整理汇总了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
}
示例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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例8: curopWaitingForLock
void curopWaitingForLock( int type ){
Client * c = currentClient.get();
assert( c );
CurOp * co = c->curop();
if ( co ){
co->waitingForLock( type );
}
}
示例9: curopGotLock
void curopGotLock(){
Client * c = currentClient.get();
assert(c);
CurOp * co = c->curop();
if ( co ){
co->gotLock();
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
}
示例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));
}
示例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;
}