inline void worker( std::uint64_t updates ) { global_scratch.reset(new double); for (double i = 0.; i < updates; ++i) *global_scratch += 1. / (2. * i + 1.); global_scratch.reset(); }
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; } }
std::shared_ptr<CoreContext> CoreContext::SetCurrent(const std::shared_ptr<CoreContext>& ctxt) { const auto& currentContext = CurrentContextOrNull(); // Short-circuit test, no need to proceed if we aren't changing the context: if (currentContext == ctxt) return currentContext; // Value is changing, update: auto retVal = currentContext; if (ctxt) autoCurrentContext.reset(new std::shared_ptr<CoreContext>(ctxt)); else autoCurrentContext.reset(); return retVal; }
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; }
static ClientConnections* threadInstance() { ClientConnections* cc = _perThread.get(); if ( ! cc ) { cc = new ClientConnections(); _perThread.reset( cc ); } return cc; }
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; } }
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_ << " ] "; };
virtual bool run(OperationContext* txn, const string&, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result) { const string fromDb = cmdObj.getStringField("fromdb"); 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))); BSONElement mechanismElement; Status status = bsonExtractField(cmdObj, saslCommandMechanismFieldName, &mechanismElement); if (!status.isOK()) { return appendCommandStatus(result, status); } BSONElement payloadElement; status = bsonExtractField(cmdObj, saslCommandPayloadFieldName, &payloadElement); if (!status.isOK()) { log() << "Failed to extract payload: " << status; return false; } authConn_.reset(cs.connect(errmsg)); if (!authConn_.get()) { return false; } BSONObj ret; if( !authConn_->runCommand( fromDb, BSON( "saslStart" << 1 << mechanismElement << payloadElement), ret ) ) { return appendCommandStatus(result, Command::getStatusFromCommandResult(ret)); } result.appendElements( ret ); return true; }
/** 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; }
/** 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; }
Glob::Glob(const std::string& pattern, GlobFlags flags) { globObject.reset(this); posix::glob_t glob; posix::glob(pattern.c_str(), flags, &onGlobError, &glob); globObject.release(); if (glob.gl_pathc) { for (char** p = glob.gl_pathv; *p != NULL; ++p) { pathNames_.push_back(*p); } } posix::globfree(&glob); }
virtual bool run(const string& , 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(); } authConn_.reset( new DBClientConnection() ); BSONObj ret; { dbtemprelease t; if ( !authConn_->connect( fromhost, errmsg ) ) return false; if( !authConn_->runCommand( "admin", BSON( "getnonce" << 1 ), ret ) ) { errmsg = "couldn't get nonce " + string( ret ); return false; } } result.appendElements( ret ); return true; }
void unlock () { this_thread_hierarchy_value.reset(new unsigned long(previous_hierarchy_value)); internal_mutex.unlock (); }
void update_hierarchy_value () { previous_hierarchy_value = *this_thread_hierarchy_value; this_thread_hierarchy_value.reset(new unsigned long(hierarchy_value)); }
void CoreContext::EvictCurrent(void) { autoCurrentContext.reset(); }