本文整理汇总了C++中thread_specific_ptr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ thread_specific_ptr::get方法的具体用法?C++ thread_specific_ptr::get怎么用?C++ thread_specific_ptr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thread_specific_ptr
的用法示例。
在下文中一共展示了thread_specific_ptr::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
std::shared_ptr<CoreContext> CoreContext::CurrentContext(void) {
if(!autoCurrentContext.get())
return std::static_pointer_cast<CoreContext, GlobalCoreContext>(GetGlobalContext());
std::shared_ptr<CoreContext>* retVal = autoCurrentContext.get();
assert(retVal);
assert(*retVal);
return *retVal;
}
示例2: ScopeCache
/** Get a scope from the pool of scopes matching the supplied pool name */
auto_ptr<Scope> ScriptEngine::getPooledScope(const string& pool) {
if (!scopeCache.get())
scopeCache.reset(new ScopeCache());
Scope* s = scopeCache->get(pool);
if (!s)
s = newScope();
auto_ptr<Scope> p;
p.reset(new PooledScope(pool, s));
return p;
}
示例3: ScopeCache
/** Get a scope from the pool of scopes matching the supplied pool name */
auto_ptr<Scope> ScriptEngine::getPooledScope(const string& pool, const string& scopeType) {
if (!scopeCache.get())
scopeCache.reset(new ScopeCache());
Scope* s = scopeCache->get(pool + scopeType);
if (!s)
s = newScope();
auto_ptr<Scope> p;
p.reset(new PooledScope(pool + scopeType, s));
p->setLocalDB(pool);
p->loadStored(true);
return p;
}
示例4: checkTSSInit
void checkTSSInit()
{
if(m_transactionInProgress.get() == 0)
{
m_transactionInProgress.reset(new bool);
(*m_transactionInProgress) = false;
}
if(m_transaction.get() == 0)
{
m_transaction.reset(new DbTxn *);
(*m_transaction) = NULL;
}
}
示例5: run
virtual bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
string fromhost = cmdObj.getStringField("fromhost");
if ( fromhost.empty() ) {
/* copy from self */
stringstream ss;
ss << "localhost:" << cmdLine.port;
fromhost = ss.str();
}
string fromdb = cmdObj.getStringField("fromdb");
string todb = cmdObj.getStringField("todb");
if ( fromhost.empty() || todb.empty() || fromdb.empty() ) {
errmsg = "parms missing - {copydb: 1, fromhost: <hostname>, fromdb: <db>, todb: <db>}";
return false;
}
Cloner c;
string username = cmdObj.getStringField( "username" );
string nonce = cmdObj.getStringField( "nonce" );
string key = cmdObj.getStringField( "key" );
if ( !username.empty() && !nonce.empty() && !key.empty() ) {
uassert( 13008, "must call copydbgetnonce first", authConn_.get() );
BSONObj ret;
{
dbtemprelease t;
if ( !authConn_->runCommand( fromdb, BSON( "authenticate" << 1 << "user" << username << "nonce" << nonce << "key" << key ), ret ) ) {
errmsg = "unable to login " + string( ret );
return false;
}
}
c.setConnection( authConn_.release() );
}
Client::Context ctx(todb);
bool res = c.go(fromhost.c_str(), errmsg, fromdb, /*logForReplication=*/!fromRepl, /*slaveok*/false, /*replauth*/false, /*snapshot*/true);
return res;
}
示例6: run
virtual bool run(OperationContext* txn,
const string&,
BSONObj& cmdObj,
int,
string& errmsg,
BSONObjBuilder& result) {
string fromhost = cmdObj.getStringField("fromhost");
if ( fromhost.empty() ) {
/* copy from self */
stringstream ss;
ss << "localhost:" << serverGlobalParams.port;
fromhost = ss.str();
}
const ConnectionString cs(uassertStatusOK(ConnectionString::parse(fromhost)));
authConn_.reset(cs.connect(errmsg));
if (!authConn_.get()) {
return false;
}
BSONObj ret;
if( !authConn_->runCommand( "admin", BSON( "getnonce" << 1 ), ret ) ) {
errmsg = "couldn't get nonce " + ret.toString();
return false;
}
result.appendElements( ret );
return true;
}
示例7: threadInstance
static ClientConnections* threadInstance() {
ClientConnections* cc = _perThread.get();
if ( ! cc ) {
cc = new ClientConnections();
_perThread.reset( cc );
}
return cc;
}
示例8: bool
disable_syscall_interruption() {
if (_syscalls_interruptable.get() == NULL) {
last_value = true;
_syscalls_interruptable.reset(new bool(false));
} else {
last_value = *_syscalls_interruptable;
*_syscalls_interruptable = false;
}
}
示例9: operator
ostream & operator()() {
ThreadOutputStream * tos( threadOutputStream_.get() );
if( tos == nullptr ) {
tos = new ThreadOutputStream();
threadOutputStream_.reset( tos );
}
return (*tos) << boost::posix_time::microsec_clock::universal_time() <<
' ' << format("%014s") % boost::this_thread::get_id() <<
" [ " << format("%-20.20s") % name_ << " ] ";
};
示例10: log
virtual ~PooledScope(){
ScopeCache * sc = scopeCache.get();
if ( sc ){
sc->done( _pool , _real );
_real = 0;
}
else {
log() << "warning: scopeCache is empty!" << endl;
delete _real;
_real = 0;
}
}
示例11: LOG
virtual ~PooledScope() {
ScopeCache* sc = scopeCache.get();
if (sc) {
sc->done(_pool, _real);
_real = NULL;
}
else {
// this means that the Scope was killed from a different thread
// for example a cursor got timed out that has a $where clause
LOG(3) << "warning: scopeCache is empty!" << endl;
delete _real;
_real = 0;
}
}
示例12:
restore_syscall_interruption(const disable_syscall_interruption &intr) {
assert(_syscalls_interruptable.get() != NULL);
last_value = *_syscalls_interruptable;
*_syscalls_interruptable = intr.last_value;
}
示例13:
const std::shared_ptr<CoreContext>& CoreContext::CurrentContextOrNull(void) {
static const std::shared_ptr<CoreContext> empty;
auto retVal = autoCurrentContext.get();
return retVal ? *retVal : empty;
}
示例14: threadDone
void ScriptEngine::threadDone(){
ScopeCache * sc = scopeCache.get();
if ( sc ){
sc->clear();
}
}
示例15: expiredContext
CoreContext::~CoreContext(void) {
// Evict from the parent's child list first, if we have a parent:
if(m_pParent)
{
expiredContext();
// Also clear out any parent pointers:
std::lock_guard<std::mutex> lk(m_pParent->m_stateBlock->m_lock);
m_pParent->m_children.erase(m_backReference);
}
// The autoCurrentContext pointer holds a shared_ptr to this--if we're in a dtor, and our caller
// still holds a reference to us, then we have a serious problem.
assert(
!autoCurrentContext.get() ||
!autoCurrentContext.get()->use_count() ||
autoCurrentContext.get()->get() != this
);
// Notify all ContextMember instances that their parent is going away
onTeardown(*this);
// Tell all context members that we're tearing down:
for(ContextMember* q : m_contextMembers)
q->NotifyContextTeardown();
// Perform unlinking, if requested:
if(m_unlinkOnTeardown)
for (const auto& ccType : m_concreteTypes) {
uint8_t* pBase = (uint8_t*)ccType.value.ptr();
// Enumerate all slots and unlink them one at a time
for (auto cur = ccType.stump->pHead; cur; cur = cur->pFlink) {
if (cur->autoRequired)
// Only unlink slots that were Autowired. AutoRequired slots will never participate
// in a cycle (because we would wind up with constructive chaos) so we don't really
// need to worry about them. Furthermore, there are cases where users may want to
// refer to a context member in their destructor; in that case, they should use
// AutoRequired to enforce the relationship.
continue;
auto& slot = *reinterpret_cast<DeferrableAutowiring*>(pBase + cur->slotOffset);
if (!slot.IsAutowired())
// Nothing to do here, just short-circuit
continue;
auto q = m_typeMemos.find(slot.GetType());
if (q == m_typeMemos.end())
// Weird. A slot is present on a member of this context, but the wired type doesn't
// have a memo entry anywhere.
continue;
if (!q->second.m_local)
// Entry exists, but was not locally satisfied. We can circle around.
continue;
// OK, interior pointer and context teardown is underway, clear it out
slot.reset();
}
}
}