Skip to content

Commit

Permalink
Throw exceptions if the context isn't running during a call to begin()
Browse files Browse the repository at this point in the history
It's easy to make this mistake--because the main thread is often the one making the call to begin, do not allow users to block on a call to `autowiring::parallel::begin` until after the context is started.

Fixes #688
  • Loading branch information
codemercenary committed Jul 30, 2015
1 parent 7d366fa commit 6650b10
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions autowiring/Parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class parallel {
// Get an iterator to the begining of out queue of job results
template<typename T>
parallel_iterator<T> begin(void) {
if (!m_ctxt->IsRunning())
if (m_ctxt->IsShutdown())
throw std::runtime_error("Attempted to enumerate members of a context after the context was shut down");
else
throw std::runtime_error("Start the context before attempting to enumerate members of an autowiring::parallel collection");
return{ *this, m_outstandingCount };
}

Expand Down

0 comments on commit 6650b10

Please sign in to comment.