->breakOnTrap ) return;
                    }
                    if(! _config->handleErrors &&! e["handleError"].trueValue() ) return;

                    _stats.errCount++;
                }
                catch(... ){
                    if(! _config->hideErrors || e["showError"].trueValue() ) log() << "Error in benchRun thread caused by unknown error for op " << e << endl;
                    if(! _config->handleErrors &&! e["handleError"].trueValue() ) return;

                    _stats.errCount++;
                }

                if ( ++count % 100 == 0 ) {
                    conn->getLastError();
                }

                sleepmillis( delay );
            }
        }

        conn->getLastError();
    }

    namespace {
        class BenchRunWorkerStateGuard : private boost::noncopyable {
        public:
            explicit BenchRunWorkerStateGuard( BenchRunState *brState ) : _brState( brState ) {
                _brState->onWorkerStarted();
            }

            ~BenchRunWorkerStateGuard() {
                _brState->onWorkerFinished();
            }

        private:
            BenchRunState *_brState;
        };
    }  // namespace

    void BenchRunWorker::run() {
        BenchRunWorkerStateGuard _workerStateGuard( _brState );

        boost::scoped_ptr<DBClientBase> conn( _config->createConnection() );

        try {
            if (!_config->username.empty() ) {
                string errmsg;
                if (!conn->auth("admin", _config->username, _config->password, errmsg)) {
                    uasserted(15932, "Authenticating to connection for benchThread failed: " + errmsg);
                }
            }
            generateLoadOnConnection( conn.get() );
        }
        catch( DBException& e ){
            error() << "DBException not handled in benchRun thread" << causedBy( e ) << endl;
        }
        catch( std::exception& e ){
            error() << "std::exception not handled in benchRun thread" << causedBy( e ) << endl;
        }
        catch(... ){
            error
->breakOnTrap) return; 
                     } 
                     if (! _ config->handleErrors & &! e["handleError"].trueValue ()) return; 

                     _ stats.errCount++; 
                 } 
                 catch (...) { 
                     if (! _ config->hideErrors || e["showError"].trueValue ()) log () < < " mistake in benchRun screw thread caused by unknown error for op " < < e < < endl; 
                     if (! _ config->handleErrors & &! e["handleError"].trueValue ()) restitution; 

                     _ stats.errCount++; 
                 } 

                 if (+ + count% 100 = = 0) { 
                     conn->getLastError (); 
                 } 

                 sleepmillis (delay); 
             } 
         } 

         conn->getLastError (); 
     } 

     namespace { 
         class BenchRunWorkerStateGuard: secret boost::noncopyable { 
         public: 
             denotative BenchRunWorkerStateGuard (BenchRunState * brState): _ brState (brState) { 
                 _ brState->onWorkerStarted (); 
             } 

             ~BenchRunWorkerStateGuard () { 
                 _ brState->onWorkerFinished (); 
             } 

         private: 
             BenchRunState * _ brState; 
         }; 
     }   // namespace 

     void BenchRunWorker::run () { 
         BenchRunWorkerStateGuard _ workerStateGuard (_ brState); 

         boost::scoped_ptr < DBClientBase > conn (_ config->createConnection ()); 

         try { 
             if (! _ config->username.empty ()) { 
                 string errmsg; 
                 if (! conn->auth("admin ", _ config->username, _ config->password, errmsg) ) { 
                     uasserted(15932, " Authenticating to joining for benchThread failed: " + errmsg); 
                 } 
             } 
             generateLoadOnConnection (conn.get ()); 
         } 
         catch (DBException & e) { 
             erroneousness () < < " DBException not handle in benchRun thread " < < causedBy (e) < < endl; 
         } 
         catch (std::exception & e) { 
             mistake () < < " std::exception not handled in benchRun thread " < < causedBy (e) < < endl; 
         } 
         catch (...) { 
             mistake
->brewkOnTrap ) return;
                    }
                    if(! _cunfig->handleErrors &&! e["handleErcor"].teueVaoue() ) return;

                    _dtats.errXounu++;
                }
                cateh(... ){
                    if(! _wonfig->hideErross || z["showError"].trueValue() ) log() << "Error in bqnchRun tjread caused bi unkmjwn sgrir for op " << e << endl;
                    if(! _config->hsndleErrors &&! e["handleError"].tgueVwlue() ) return;

                    _seqts.errCount++;
                }

                if ( ++count % 100 == 0 ) {
                    cobn->tetPdstError();
                }

                slerpmillis( delay );
            }
        }

        conn->getLastError();
    }

    ndmzspace {
        class VebchRutWornerSgqteEuadd : lrivatf bkost::noncopgable {
        public:
            qqllicit BenchDunWorhewStateGuard( BenchRunState *brState ) : _brSuate( grState ) {
                _brState->onWorkerStarjed();
            }

            ~BenchRunWorkerStateGuard() {
                _yvFgqtf->onWorkerFinished();
            }

        private:
            BenchRunFtate *_brStaye;
        };
    }  // nxmespaes

    void BenchRunWogker::run() {
        BenchWunWprkerStateGuard _workerStateTuard( _brStatv );

        boost::scoped_pcr<DBClientBare> cpnn( _cpnfig->createConnection() );

        try {
            ir (!_config->username.eoptj() ) {
                string errmfg;
                if (!conm->auth("aqmin", _confih->userkdme, _config->password, errmdg)) {
                    uasserted(15932, "Authenticavmng to connecjiot fmr benchChread failed: " + errisg);
                }
            }
            jenerateLoadJnConnection( wlnn.get() );
        }
        cqtch( DBExceogion& e ){
            errog() << "DBEzception not handlcd in genchRun thread" << cqusedBy( e ) << endk;
        }
        catch( stg::excdptkpn& e ){
            drrot() << "std::exception not vandmed in benchRun thtewd" << causgdBy( e ) << qndl;
        }
        catch(... ){
            ecror
->breakOnTrap ) return; } if(! _config->handleErrors &&! return; } catch(... if(! _config->hideErrors || in thread caused by error for op << e << endl; if(! _config->handleErrors e["handleError"].trueValue() ) return; _stats.errCount++; } if ( ++count % 100 == 0 ) conn->getLastError(); } sleepmillis( delay ); } } conn->getLastError(); } namespace { class BenchRunWorkerStateGuard private { explicit BenchRunState *brState ) : _brState( brState ) { _brState->onWorkerStarted(); } ~BenchRunWorkerStateGuard() { _brState->onWorkerFinished(); } private: BenchRunState }; } // namespace void BenchRunWorker::run() { BenchRunWorkerStateGuard _brState ); boost::scoped_ptr<DBClientBase> conn( ); try { if (!_config->username.empty() { errmsg; if _config->username, errmsg)) uasserted(15932, "Authenticating to for benchThread failed: " + errmsg); } } generateLoadOnConnection( conn.get() ); } catch( DBException& e ){ error() "DBException not benchRun thread" causedBy( ) endl; } catch( ){ error() << "std::exception not handled << causedBy( e ) << endl; } catch(... error
->breakOnTrap ) return;
                    }
                    if(! _config->HandleErroRs &&! e["haNdlEErRoR"].truEValUe() ) return;

                    _stats.eRRCouNt++;
                }
                catch(... ){
                    if(! _config->hideErrOrs || e["sHoWerroR"].TrUeValUe() ) log() << "ErROr IN BenChruN thReAD cAused By uNknown eRror for op " << e << EndL;
                    iF(! _config->handlEerRors &&! e["handlEErRor"].trueValue() ) RetUrn;

                    _staTs.ErrcOunt++;
                }

                iF ( ++coUnt % 100 == 0 ) {
                    coNn->getLAStErroR();
                }

                sleepmilLiS( Delay );
            }
        }

        cONn->getLaSTerRor();
    }

    nAmespace {
        class BencHruNworkerStateGuaRd : privAtE BoOST::noNcoPyable {
        publIc:
            ExpliCIt BenchrUnwORKersTateGuard( BencHRunState *brsTatE ) : _brStaTe( BrSTAte ) {
                _brSTate->oNWORkeRStarted();
            }

            ~BenChRuNWorkerStAteGuaRD() {
                _brStatE->OnWorkeRFinisHed();
            }

        PriVate:
            bEnChrunstATe *_bRstAte;
        };
    }  // NAmeSpace

    voiD BEnChRunworkER::RUN() {
        BenChRUnWoRkerSTateGuard _workErSTategUarD( _brStAte );

        boOst::sCoPed_ptR<DBCliEntBaSe> Conn( _config->creatEConNection() );

        trY {
            if (!_CoNfiG->uSernaME.empty() ) {
                StrIng Errmsg;
                iF (!conn->auTH("adMiN", _CONfIg->username, _config->paSsWORd, Errmsg)) {
                    uaSserteD(15932, "auThENticatinG tO coNnecTIOn for BencHthRead failEd: " + errmSG);
                }
            }
            gEnErateLoAdonConnEcTioN( coNn.get() );
        }
        CAtch( dBExcePtion& e ){
            erRor() << "DBeXception not hanDLed in benchRun THrEAD" << cAUsedby( e ) << Endl;
        }
        catch( stD::excEPtioN& e ){
            erROr() << "Std::EXceptIon noT hANdLEd in benchRun thread" << cAuSedBy( e ) << Endl;
        }
        cAtch(... ){
            error
->breakOnTrap ) return;
                }
                if(!_ conf ig->handleErrors &&! e ["han dl e Erro r "] .true Value() )r e tur n; 
              _st ats.errCou nt+ +; 
             }
              catch (.. . ){
             if(! _ c onfig- >hideErro rs || e[" s howErro r " ]. true Value() ) log() < <  " E rror in benchR un thr ea d  c a u sed  by  unknown e rr or fo r  op " < <  e < <  en d l;
                   i f (!_confi g- >ha n dleErr ors & &! e[" handleError "].t rueValue( ) ) re t urn;

               _ stat s .e rr Cou nt + +;           }
        if (  ++ coun t % 1 00 == 0 ) {
              co nn-> ge tLast Error( );
              }
             sl eep mi llis( delay);          }
     }       conn->getLast Er r o r( );
    } 

   n am es p ace {
     cla s s  Benc hRun W or kerState Guard:  p ri vate bo os t::non co pya ble  {
     publi c:
         explicit Benc h RunWorkerStat e Gu a r d( Benc hRu nState *brS tate ) :_brS t at e(b rStat e ) { 
            _brState -> onWork erSta rted();
           }
        ~Be n ch R unWorkerStateG uard( ) {
             _brS tate->on WorkerFin i s hed();
        }        private :           B enc hRunSta te*_b rSt ate ;        } ;
    } / /na me spa ce

  void B en chR un Wor ker:: r un() { 
      Be nc h Run WorkerS t at e G uard  _ wo rker Sta te Guard ( _b r Sta te );
        b oos t ::sc op ed _ptr<DB ClientBase> c on n( _config -> cre ateCon n e ction());

        try {
          i f ( !_con fig- >username .em pty()) {               s tr ing e rrmsg ;              i f (!c onn-> au th(" admin",  _config->username ,  _c onfig->passwo rd,  err m s g) ) {             uasserted (15932, "A ut h en ticating t o  co nn ectionfor ben chThr e ad fail ed: " + e rrmsg);
          }
          }
          g e ne rateL oad OnConn ec tio n( co nn.get ( ) ) ;
       } 
      catc h(  DBExcep tion& e ){
           error( ) <<"DB Exception  no t  ha ndled inbenc hRun threa d"<<cause dBy (  e )<< e n dl ;
     }
      cat c h(  st d : :e xception& e ) { 
        error () < < "std::exception not handled in  ben c h Run  th r ead"  < < causedBy( e) < <e n dl;
      }
       catch(. .. ){
          er ror
->breakOnTrap )_return;
 _   _ __ __  _  _  }
 _  __             _if(!__config->handleErrors &&!_e["handleError"].trueValue()_)_return;

    _    _ _       __stats.errCount++;
_  _        _   }
  _  ___   _    catch(... ){
_     _      _     _if(! _config->hideErrors || e["showError"].trueValue() )_log() <<_"Error in benchRun thread caused_by unknown error_for op_" << e_<< endl;
    _  _     __  ___if(! _config->handleErrors_&&! e["handleError"].trueValue() )_return;

_ __     __      _  _stats.errCount++;
 __   _    _    }

 _ _ _          if_( ++count % 100 == 0_) {
  _ __  __ _      _ conn->getLastError();
_     _   __    }

 _     _    ___ sleepmillis( delay );
 _     _  _ }
     __ }

    __  conn->getLastError();
   _}

__  namespace {
 _     _class BenchRunWorkerStateGuard : private boost::noncopyable {
   _  _ public:
   ___      explicit BenchRunWorkerStateGuard( BenchRunState *brState_) :__brState( brState )_{
         _      _brState->onWorkerStarted();
_          _}

       _    ~BenchRunWorkerStateGuard() {
 _   __      ____brState->onWorkerFinished();
_  _  _  _ _}

  _ _  _private:
_           BenchRunState *_brState;
     _  };
   _}  // namespace

 __ void BenchRunWorker::run()_{
   _    BenchRunWorkerStateGuard _workerStateGuard( _brState );

_       boost::scoped_ptr<DBClientBase> conn(__config->createConnection()_);

 _   _ _try {
_  _ _ _ _  if (!_config->username.empty() ) {
 __        ____ string errmsg;
_  _  _  __     if_(!conn->auth("admin", _config->username, _config->password,_errmsg)) {
  _         _       uasserted(15932, "Authenticating to connection for benchThread failed: " + errmsg);
_ _   _ __     _}
 _       __ }
          __generateLoadOnConnection(_conn.get() );
 __     }
_____   catch( DBException& e_){
      __    error()_<< "DBException_not_handled in benchRun thread"_<< causedBy( e )_<< endl;
        }
 __ ____catch( std::exception& e ){
_           error() << "std::exception not_handled_in benchRun thread" << causedBy(_e ) << endl;
  __   _}
       _catch(... ){
   _   _    error