in Source/Shared/arcana/threading/internal/internal_task.h [231:265]
void internal_add_continuations(gsl::span<continuation_payload> continuations)
{
if (m_completed)
throw std::runtime_error("already specified a continuation for the current task");
assert(!continuations.empty() && "we shouldn't be calling this with an empty continuation set");
if (auto vect = std::get_if<1>(&m_continuation))
{
vect->insert(
vect->end(), std::make_move_iterator(continuations.begin()), std::make_move_iterator(continuations.end()));
}
else if (!std::get<0>(m_continuation) && continuations.size() == 1)
{
std::get<0>(m_continuation) = std::move(continuations.at(0));
}
else
{
// create a vector with the existing continuation (if there is one)
// then append the new ones.
if (std::get<0>(m_continuation))
{
m_continuation = std::vector<continuation_payload>{ std::move(std::get<0>(m_continuation)) };
std::get<1>(m_continuation).insert(
std::get<1>(m_continuation).end(),
std::make_move_iterator(continuations.begin()), std::make_move_iterator(continuations.end()));
}
else
{
m_continuation = std::vector<continuation_payload>(
std::make_move_iterator(continuations.begin()), std::make_move_iterator(continuations.end()));
}
}
}