in rpc/out-of-order-execution.cpp [61:106]
int issue_operation(OutOfOrderContext& args) //firing issue
{
SCOPED_LOCK(m_mutex_w);
m_issuing ++;
DEFER(m_issuing --);
if (!m_running)
LOG_ERROR_RETURN(ESHUTDOWN, -1, "engine is been shuting down");
if (!args.flag_tag_valid)
{
again:
args.tag = ++m_tag; // auto increase if it is not user defined tag
}
args.th = CURRENT;
{
SCOPED_LOCK(args.phaselock);
args.phase = OooPhase::BEFORE_ISSUE;
}
args.ret = 0;
{
SCOPED_LOCK(m_mutex_map);
auto ret = m_map.insert({args.tag, &args}); //the return value is {iter, bool}
if (!ret.second) // means insert failed because of key already exists
{
auto tag = args.tag;
auto th = (ret.first == m_map.end()) ? nullptr : ret.first->second->th;
LOG_ERROR("failed to insert record into unordered hash map",
VALUE(tag), VALUE(CURRENT), VALUE(th));
if (args.flag_tag_valid) // user set tag, need to tell user it is a failure
LOG_ERROR_RETURN(EINVAL, -1, "the tag in argument is NOT valid");
goto again;
}
}
int ret2 = args.do_issue(&args);
if (ret2 < 0) {
SCOPED_LOCK(m_mutex_map);
m_map.erase(args.tag);
m_cond_collected.notify_one();
LOG_ERROR_RETURN(0, -1, "failed to do_issue()");
}
{
SCOPED_LOCK(args.phaselock);
args.phase = OooPhase::ISSUED;
}
return 0;
}