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


C++ rollback函数代码示例

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


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

示例1: rollback

Transaction::~Transaction()
{
  // Either this Transaction shell was not committed (first condition)
  // or the commit failed (we are still active and need to rollback)
  if (!committed_ || impl_->needsRollback_) {
    // A commit attempt failed (and thus we need to rollback) or we
    // are unwinding a stack while an exception is thrown
    if (impl_->needsRollback_ || std::uncaught_exception()) {
      try {
	rollback();
      } catch (std::exception& e) {
	release();
	throw;
      }
    } else {
      try {
	commit();
      } catch (std::exception& e) {
	try {
	  if (impl_->transactionCount_ == 1)
	    rollback();
	} catch (std::exception& e) {
	  std::cerr << "Unexpected transaction during Transaction::rollback()"
		    << std::endl;
	}

	release();
	throw;
      }
    }
  }

  release();
}
开发者ID:ScienziatoBestia,项目名称:wt,代码行数:34,代码来源:Transaction.C

示例2: if

void zmq::pipe_t::terminate (bool delay_)
{
    //  Overload the value specified at pipe creation.
    delay = delay_;

    //  If terminate was already called, we can ignore the duplicate invocation.
    if (state == term_req_sent1 || state == term_req_sent2) {
        return;
    }
    //  If the pipe is in the final phase of async termination, it's going to
    //  closed anyway. No need to do anything special here.
    else if (state == term_ack_sent) {
        return;
    }
    //  The simple sync termination case. Ask the peer to terminate and wait
    //  for the ack.
    else if (state == active) {
        send_pipe_term (peer);
        state = term_req_sent1;
    }
    //  There are still pending messages available, but the user calls
    //  'terminate'. We can act as if all the pending messages were read.
    else if (state == waiting_for_delimiter && !delay) {
        //  Drop any unfinished outbound messages.
        rollback ();
        outpipe = NULL;
        send_pipe_term_ack (peer);
        state = term_ack_sent;
    }
    //  If there are pending messages still available, do nothing.
    else if (state == waiting_for_delimiter) {
    }
    //  We've already got delimiter, but not term command yet. We can ignore
    //  the delimiter and ack synchronously terminate as if we were in
    //  active state.
    else if (state == delimiter_received) {
        send_pipe_term (peer);
        state = term_req_sent1;
    }
    //  There are no other states.
    else {
        zmq_assert (false);
    }

    //  Stop outbound flow of messages.
    out_active = false;

    if (outpipe) {

        //  Drop any unfinished outbound messages.
        rollback ();

        //  Write the delimiter into the pipe. Note that watermarks are not
        //  checked; thus the delimiter can be written even when the pipe is full.
        msg_t msg;
        msg.init_delimiter ();
        outpipe->write (msg, false);
        flush ();
    }
}
开发者ID:AmesianX,项目名称:libzmq,代码行数:60,代码来源:pipe.cpp

示例3: begin

int RecorderDAO::DeleteRecorder(SITE_T * site, RECORDER_T * recorder, sqlite3 * connection)
{
	int value = DAO_FAIL;
	sqlite3_stmt *stmt;

	sqlite3 *conn;
	if (connection == 0)
		conn = _db;
	else
		conn = connection;

	if (!site || !recorder)
		return value;

	begin(conn);

	if (sqlite3_prepare(conn, "DELETE FROM tb_site_recorder WHERE site_uuid=? and recorder_uuid=?;", -1, &stmt, 0) == SQLITE_OK)
	{
		sqlite3_bind_text16(stmt, 1, site->uuid, -1, 0);
		sqlite3_bind_text16(stmt, 2, recorder->uuid, -1, 0);
		int result = sqlite3_step(stmt);
		if (result == SQLITE_DONE)
		{
			value = DAO_SUCCESS;
		}
	}
	sqlite3_reset(stmt);
	sqlite3_finalize(stmt);
	if (value != DAO_SUCCESS)
	{
		rollback(conn);
		return value;
	}

	if (sqlite3_prepare(conn, "DELETE FROM tb_recorder WHERE uuid=?;", -1, &stmt, 0) == SQLITE_OK)
	{
		sqlite3_bind_text16(stmt, 1, recorder->uuid, -1, 0);
		int result = sqlite3_step(stmt);
		if (result == SQLITE_DONE)
		{
			value = DAO_SUCCESS;
		}
	}
	sqlite3_reset(stmt);
	sqlite3_finalize(stmt);
	if (value != DAO_SUCCESS)
	{
		rollback(conn);
		return value;
	}

	commit(conn);
	return value;
}
开发者ID:nemeyes,项目名称:ht-recorder-client,代码行数:54,代码来源:RecorderDAO.cpp

示例4: xrecall

void 
xrecall (int *nerr) {
        /*=====================================================================
         * PURPOSE:  To execute the action command RECALL.
         *           Files in SAC are copied to SeisMgr 
         *=====================================================================
         * INPUT ARGUMENTS:
         *    KINPUT:  Character string containing options
         *             Note, this command is not parsed by the standard SAC
	 *             parsing mechanism.
         *=====================================================================
         * OUTPUT ARGUMENTS:
         *    NERR:    Error flag. Set to 0 if no error occurred.
         *=====================================================================
         * MODULE/LEVEL: SSI/2
         *=====================================================================
         * GLOBAL INPUT:
         *    SSI:     LDATA
         *=====================================================================
         * MODIFICATION HISTORY:
	 *	980915:	Original version.
         *=====================================================================*/

    *nerr = 0 ;

    sacToSeisMgr ( 0 , 1 , 0 , nerr ) ;
    rollback ( wfHeader , nerr ) ;
}
开发者ID:wjlei1990,项目名称:WORKFLOW,代码行数:28,代码来源:xblend.c

示例5: value

REAL   value(   PrivGlobs    globs,
                const REAL s0,
                const REAL strike,
                const REAL t,
                const REAL alpha,
                const REAL nu,
                const REAL beta,
                const unsigned int numX,
                const unsigned int numY,
                const unsigned int numT
) {
    initGrid(s0,alpha,nu,t, numX, numY, numT, globs);
    initOperator(globs.myX,globs.myDxx);
    initOperator(globs.myY,globs.myDyy);

    setPayoff(strike, globs);
    // globs is global and cannot be privatized thus this loop cannot be
    // parallelized yet.
    // If updateParams and rollback is independent on i and globs, loop can be
    // parallelized by privatization of initGrid, initOperator and setPayoff calls.
    // If they write indepedently to globs, privatization is not needed.
    for(int i = globs.myTimeline.size()-2;i>=0;--i) // seq
    {
        updateParams(i,alpha,beta,nu,globs);
        rollback(i, globs);
    }

    return globs.myResult[globs.myXindex][globs.myYindex];
}
开发者ID:martinnj,项目名称:PMPH2015-G,代码行数:29,代码来源:ProjCoreOrig.cpp

示例6: main

int main(){
    while(scanf("%d" , &total) == 1){
        if((total >= 0) && (total < 25)){
            break;
        }
    }
    init_list();
    char act[5] , kind[5];
    int a , b , cmd;
    while(scanf("%s" , act) == 1){
        if(act[0] == 'q'){
            break;
        }else{
            scanf("%d %s %d" , &a , kind , &b);
            if((a == b ) || ((a > total) && (b > total))){
                continue;
            }
            Blocks *a_block = find_node(a);
            Blocks *b_block = find_node(b);
            if(a_block->cur_addr == b_block->cur_addr){
                continue;
            }

            if(act[0] == 'm'){
                cmd = 10;
            }else{
                cmd = 20;
            }

            if(kind[1] == 'n'){
                cmd += 1;
            }else{
                cmd += 2;
            }
            switch(cmd){
                case 11:
                    rollback(a_block);
                    rollback(b_block);
                    break;
                case 12:
                    rollback(a_block);
                    break;
                case 21:
                    rollback(b_block);
                    break;
                case 22:
                    break;
            }
            move(a_block , b_block->cur_addr);
        }
    }
    display();
    return 0;
}
开发者ID:a147017,项目名称:acm,代码行数:54,代码来源:101.c

示例7: TRANSATION_EVENT

bool CoreBase::runTransaction(TransactionBlock transaction,
                              TransactionEvent event,
                              Error &error)
{
#define TRANSATION_EVENT(eventType)                                            \
    if (event) {                                                               \
        event(eventType);                                                      \
    }
    if (!begin(StatementTransaction::Mode::Immediate, error)) {
        TRANSATION_EVENT(TransactionEventType::BeginFailed);
        return false;
    }
    if (transaction(error)) {
        error.reset(); //User discards error
        if (commit(error)) {
            return true;
        }
        TRANSATION_EVENT(TransactionEventType::CommitFailed);
    }
    TRANSATION_EVENT(TransactionEventType::Rollback);
    Error
        rollBackError; //Rollback errors do not need to be passed to the outside
    if (!rollback(rollBackError)) {
        TRANSATION_EVENT(TransactionEventType::RollbackFailed);
    }
    return false;
}
开发者ID:zidonJ,项目名称:Git_OC,代码行数:27,代码来源:core_base.cpp

示例8: Term

result Term() {
    result lhs = Factor(), rhs;
    token op;
    if(lhs.error !=  ERR_NONE) {
        return lhs;
    }
    for(op = next_token(); op.type == TT_ASTERISK || op.type == TT_SLASH; op = next_token() ) { 
        rhs = Factor();
#ifdef DEBUG_1
        print_result("Term:lhs:", lhs);
        printf("Term:op:%d\n", op.type);
        print_result("Term:rhs:", rhs);
#endif
        if(rhs.error != ERR_NONE) {
            return rhs;
        }
        if(op.type == TT_ASTERISK) {
            lhs.value *= rhs.value;
        }
        else if(op.type == TT_SLASH) {
            if(rhs.value != 0) {
                lhs.value /= rhs.value;
            }
            else {
                return make_result(ERR_DIVISION_BY_ZERO, 0); 
            }
        }
        else {
            return make_result(ERR_UNEXPECTED_TOKEN, 0);
        }
    }
    rollback();
    return make_result(ERR_NONE, lhs.value);
}
开发者ID:melentyev,项目名称:spbu-homework,代码行数:34,代码来源:expressinons.c

示例9: rollback

// cut selection to clipboard
void LLURLLineEditor::cut()
{
	if( canCut() )
	{
		// Prepare for possible rollback
		LLURLLineEditorRollback rollback( this );

		copyEscapedURLToClipboard();

		deleteSelection();

		// Validate new string and rollback the if needed.
		BOOL need_to_rollback = ( mPrevalidateFunc && !mPrevalidateFunc( mText.getWString() ) );
		if( need_to_rollback )
		{
			rollback.doRollback( this );
			LLUI::reportBadKeystroke();
		}
		else
		if( mKeystrokeCallback )
		{
			mKeystrokeCallback( this );
		}
	}
}
开发者ID:HyangZhao,项目名称:NaCl-main,代码行数:26,代码来源:llurllineeditorctrl.cpp

示例10: commit

    bool commit()
    {
        std::atomic_signal_fence($)(std::memory_order_release);

        size_t i;
        for (i = 0; i != rset_idx($); ++i)
        {
            rdesc const* desc = &rset[i];
            if ((*(desc->addr($)))($).load(std::memory_order_relaxed) != desc->cmp($))
                break;
        }
        if (i != rset_idx($))
        {
            return rollback();
        }

        std::atomic_thread_fence($)(std::memory_order_release);

        for (i = 0; i != wset_idx($); ++i)
        {
            wdesc const* desc = &wset[i];
            (*(desc->addr($)))($).store(desc->xchg($), std::memory_order_relaxed);
        }

        //std::atomic_thread_fence(std::memory_order_acq_rel);

        return true;
    }
开发者ID:arssivka,项目名称:2rc,代码行数:28,代码来源:rtl.hpp

示例11: rollback

void zmq::writer_t::terminate ()
{
    //  Prevent double termination.
    if (terminating)
        return;
    terminating = true;

    //  Mark the pipe as not available for writing.
    active = false;

    //  Rollback any unfinished messages.
    rollback ();

    if (swapping) {
        pending_delimiter = true;
        return;
    }

    //  Push delimiter into the pipe. Trick the compiler to belive that
    //  the tag is a valid pointer. Note that watermarks are not checked
    //  thus the delimiter can be written even though the pipe is full.
    zmq_msg_t msg;
    const unsigned char *offset = 0;
    msg.content = (void*) (offset + ZMQ_DELIMITER);
    msg.flags = 0;
    pipe->write (msg, false);
    flush ();
}
开发者ID:dermoth,项目名称:zeromq2,代码行数:28,代码来源:pipe.cpp

示例12: Expr

result Expr() {
    result lhs = Term(), rhs;
    token op;
    if(lhs.error !=  ERR_NONE) {
        return lhs;
    }
    for(op = next_token(); op.type == TT_PLUS || op.type == TT_MINUS; op = next_token() ) { 
        rhs = Term();
#ifdef DEBUG_1        
        print_result("Expr:lhs:", lhs);
        printf("Expr:op:%d\n", op.type);
        print_result("Expr:rhs:", rhs);
#endif
        if(rhs.error !=  ERR_NONE) {
            return rhs;
        }
        if(op.type == TT_PLUS) {
            lhs.value += rhs.value;
        }
        else if(op.type == TT_MINUS) {
            lhs.value -= rhs.value;
        } 
        else {
            return make_result(ERR_UNEXPECTED_TOKEN, 0);
        }
    }
    if(op.type !=  TT_END && op.type != TT_BR_CLOSE) {
        return make_result(ERR_UNEXPECTED_TOKEN, (int) op.type);    
    }
    else {
        rollback();
        return make_result(ERR_NONE, lhs.value); 
    }
}
开发者ID:melentyev,项目名称:spbu-homework,代码行数:34,代码来源:expressinons.c

示例13: value

REAL
value(const unsigned i,
      const REAL s0,
      const REAL t,
      const REAL alpha,
      const REAL nu,
      const REAL beta,
      const unsigned int numX,
      const unsigned int numY,
      const unsigned int numT)
{
  REAL strike;
  PrivGlobs    globs(numX, numY, numT);
  strike = 0.001*i;
  initGrid(s0, alpha, nu, t, numX, numY, numT, globs);
  initOperator(globs.myX, globs.myDxx);
  initOperator(globs.myY, globs.myDyy);

  setPayoff(strike, globs);
  for(int i = globs.myTimeline.size()-2; i >= 0; i--) {
    updateParams(i,alpha,beta,nu,globs);
    rollback(i, globs);
  }

  return globs.myResult[globs.myXindex][globs.myYindex];
}
开发者ID:NinnOgTonic,项目名称:PMPH,代码行数:26,代码来源:ProjCoreOrig.cpp

示例14: statusChanged

void DataImporterThread::importData()
{
    if(!beforeImportQuery.isEmpty()){
        emit statusChanged(tr("Executing before import query..."));
        sourceDb->executeQueryAndCleanup(beforeImportQuery);
    }

    emit statusChanged(tr("Importing data"));

    QStringList fileFieldNames;
    for(int i=0; i<columnMappings.size(); ++i){
        ColumnMapping *mapping = columnMappings.at(i);
        tableOptions.addColumnToCompare(mapping->columnName);

        fileFieldNames.append(mapping->fileFieldName);
    }

    QStringList originalFileFieldNames = fileFieldNames;

    qSort(fileFieldNames.begin(), fileFieldNames.end(), stringLengthDescLessThan); //first sort by length in descending order to prevent in name replacements
    for(int i=0; i<fileFieldNames.size(); ++i){
        insertQuery.replace(QString(":%1").arg(fileFieldNames.at(i)),
                            QString(":%1_%2").arg(BIND_VAR_PREFIX).arg(originalFileFieldNames.indexOf(fileFieldNames.at(i))), Qt::CaseInsensitive);
    }


    prepareBindArrays(true);

    stmt->lockConnection();
    stmt->prepare(insertQuery);
    stmt->setBindArraySize(BULK_DATA_OPERATION_CHUNK_SIZE);
    bulkHelper.bindArrays(stmt, BIND_VAR_PREFIX);
    currentOffset = 0;

    importer->resetPosition();
    importer->resetBuffer();
    importer->readRows(this);

    if(currentOffset>0){
        if(currentOffset < BULK_DATA_OPERATION_CHUNK_SIZE){
            bulkHelper.nullifyArrayData(stmt, currentOffset);
            stmt->setBindArraySize(currentOffset);
        }

        stmt->execute();
        emit chunkImported(currentOffset);
    }

    stmt->unlockConnection();

    if(!afterImportQuery.isEmpty() && !stopped){
        emit statusChanged(tr("Executing after import query..."));
        sourceDb->executeQueryAndCleanup(afterImportQuery);
    }

    if(stopped){
        rollback();
    }
}
开发者ID:rovshan-b,项目名称:oraexp,代码行数:59,代码来源:dataimporterthread.cpp

示例15: catch

void RepoTxn::step(RepoQuery& query) {
  try {
    query.step();
  } catch (const std::exception&) {
    rollback();
    throw;
  }
}
开发者ID:MarkTseng,项目名称:hiphop-php,代码行数:8,代码来源:repo_helpers.cpp


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