本文整理汇总了C++中Process::SendPreCommitToProcess方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::SendPreCommitToProcess方法的具体用法?C++ Process::SendPreCommitToProcess怎么用?C++ Process::SendPreCommitToProcess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::SendPreCommitToProcess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewCoordinatorMode
//.........这里部分代码省略.........
p->SendStateReqToAll(msg);
outf << "sent state req" << endl;
p->WaitForStates();
ProcessState my_st = p->get_my_state();
// if(p->get_pid() == 1) return NULL;
bool aborted = false;
for (const auto& ps : p->participant_state_map_) {
if (ps.second == ABORTED)
{
aborted = true;
break;
}
}
if (my_st == ABORTED || aborted)
{
if (my_st != ABORTED)
{
p->LogAbort();
//only log if other process is abort.
//if i know aborted, means already in log abort
my_st = ABORTED;
}
for (const auto& ps : p->participant_state_map_) {
p->SendAbortToProcess(ps.first);
}
p->set_my_state(ABORTED);
p->RemoveThreadFromSet(pthread_self());
return NULL;
}
bool committed = false;
for (const auto& ps : p->participant_state_map_) {
if (ps.second == COMMITTED)
{
committed = true;
break;
}
}
if (my_st == COMMITTED || committed)
{
if (my_st != COMMITTED)
{
p->LogCommit();
my_st = COMMITTED;
}
p->SendCommitToAll();
p->set_my_state(COMMITTED);
p->RemoveThreadFromSet(pthread_self());
return NULL;
}
bool uncert = true;
for (const auto& ps : p->participant_state_map_) {
if (ps.second == PROCESSTIMEOUT)continue;
if (ps.second != UNCERTAIN)
{
uncert = false;
break;
}
}
if (uncert && my_st == UNCERTAIN)
{
outf << "sending abort" << endl;
p->LogAbort();
for (const auto& ps : p->participant_state_map_) {
p->SendAbortToProcess(ps.first);
}
p->set_my_state(ABORTED);
p->RemoveThreadFromSet(pthread_self());
return NULL;
}
//else
//some are commitable
p->LogPreCommit();
outf << "sending precommit"<< endl;
for (const auto& ps : p->participant_state_map_) {
p->SendPreCommitToProcess(ps.first);
}
p->WaitForAck();
p->LogCommit();
p->set_my_state(COMMITTED);
p->SendCommitToAll();
outf << "sent commit " << endl;
if (my_st == ABORTED)
p->prev_decisions_.push_back(ABORT);
else
p->prev_decisions_.push_back(COMMIT);
p->RemoveThreadFromSet(pthread_self());
return NULL;
}