Created
August 22, 2012 02:02
-
-
Save arsenm/3421452 to your computer and use it in GitHub Desktop.
Which is better
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if 0 | |
// I'm not sure if it's safe to use the move'd workunit | |
// after insertion fails, so copy the name so we can say | |
// which one was problematic | |
const std::string workunitName = newWorkunit->name(); | |
auto inserted = m_workunits.insert(std::make_pair(newWorkunit->name(), std::move(newWorkunit))); | |
if (inserted.second) // Insertion succeeded | |
{ | |
// Actually a new workunit, this is normal. Schedule the inserted workunit | |
m_scheduler->scheduleWorkunit(*inserted.first->second); | |
} | |
else | |
{ | |
// Project screwed up, sent multiple workunits with the same name. | |
// TODO: Would it be better to interpret this as an | |
// update to the workunit? How do we handle the case | |
// where the old copy has already started? | |
rError("Workunit '%s' already exists for project '%s'", | |
workunitName.c_str(), | |
project.cname() | |
); | |
} | |
#else | |
if (m_workunits.find(newWorkunit->name()) == m_workunits.end()) | |
{ | |
// Actually a new workunit, this is normal. Schedule the inserted workunit | |
m_scheduler->scheduleWorkunit(*newWorkunit); | |
m_workunits[newWorkunit->name()] = std::move(newWorkunit); | |
} | |
else | |
{ | |
// Project screwed up, sent multiple workunits with the same name. | |
// TODO: Would it be better to interpret this as an | |
// update to the workunit? How do we handle the case | |
// where the old copy has already started? | |
rError("Workunit '%s' already exists for project '%s'", | |
newWorkunit->cname(), | |
project.cname() | |
); | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment