Skip to content

Commit

Permalink
Fix #729: Unhandled switch
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Feb 26, 2013
1 parent 4025567 commit 526079b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 11 deletions.
24 changes: 21 additions & 3 deletions hpx/runtime/threads/policies/abp_priority_queue_scheduler.hpp
Expand Up @@ -375,12 +375,21 @@ namespace hpx { namespace threads { namespace policies
return high_priority_queues_[num_thread]->get_thread_count(state);
break;
}

default:
case thread_priority_unknown:
{
HPX_THROW_EXCEPTION(bad_parameter,
"abp_priority_queue_scheduler::get_thread_count",
"unknown thread priority value (thread_priority_unknown)");
return 0;
}
}
return 0;
}

switch (priority) {
case thread_priority_default:
case thread_priority_default:
{
// Return the cumulative count for all queues.
for (std::size_t i = 0; i < high_priority_queues_.size(); ++i)
Expand All @@ -392,7 +401,7 @@ namespace hpx { namespace threads { namespace policies
count += queues_[i]->get_thread_count(state);
}

case thread_priority_low:
case thread_priority_low:
return low_priority_queue_.get_thread_count(state);

case thread_priority_normal:
Expand All @@ -402,12 +411,21 @@ namespace hpx { namespace threads { namespace policies
break;
}

case thread_priority_critical:
case thread_priority_critical:
{
for (std::size_t i = 0; i < high_priority_queues_.size(); ++i)
count += high_priority_queues_[i]->get_thread_count(state);
break;
}

default:
case thread_priority_unknown:
{
HPX_THROW_EXCEPTION(bad_parameter,
"abp_priority_queue_scheduler::get_thread_count",
"unknown thread priority value (thread_priority_unknown)");
return 0;
}
}
return count;
}
Expand Down
28 changes: 23 additions & 5 deletions hpx/runtime/threads/policies/local_priority_queue_scheduler.hpp
Expand Up @@ -391,13 +391,22 @@ namespace hpx { namespace threads { namespace policies
return high_priority_queues_[num_thread]->get_thread_count(state);
break;
}

default:
case thread_priority_unknown:
{
HPX_THROW_EXCEPTION(bad_parameter,
"local_priority_queue_scheduler::get_thread_count",
"unknown thread priority value (thread_priority_unknown)");
return 0;
}
}
return 0;
}

// Return the cumulative count for all queues.
switch (priority) {
case thread_priority_default:
case thread_priority_default:
{
for (std::size_t i = 0; i < high_priority_queues_.size(); ++i)
count += high_priority_queues_[i]->get_thread_count(state);
Expand All @@ -408,7 +417,7 @@ namespace hpx { namespace threads { namespace policies
count += queues_[i]->get_thread_count(state);
}

case thread_priority_low:
case thread_priority_low:
return low_priority_queue_.get_thread_count(state);

case thread_priority_normal:
Expand All @@ -418,12 +427,21 @@ namespace hpx { namespace threads { namespace policies
break;
}

case thread_priority_critical:
case thread_priority_critical:
{
for (std::size_t i = 0; i < high_priority_queues_.size(); ++i)
count += high_priority_queues_[i]->get_thread_count(state);
break;
}

default:
case thread_priority_unknown:
{
HPX_THROW_EXCEPTION(bad_parameter,
"local_priority_queue_scheduler::get_thread_count",
"unknown thread priority value (thread_priority_unknown)");
return 0;
}
}
return count;
}
Expand All @@ -441,7 +459,7 @@ namespace hpx { namespace threads { namespace policies
{
BOOST_ASSERT(num_thread < queues_.size());

if (num_thread < high_priority_queues_.size())
if (num_thread < high_priority_queues_.size())
{
wait_time = high_priority_queues_[num_thread]->
get_average_thread_wait_time();
Expand Down Expand Up @@ -489,7 +507,7 @@ namespace hpx { namespace threads { namespace policies
{
BOOST_ASSERT(num_thread < queues_.size());

if (num_thread < high_priority_queues_.size())
if (num_thread < high_priority_queues_.size())
{
wait_time = high_priority_queues_[num_thread]->
get_average_task_wait_time();
Expand Down
24 changes: 21 additions & 3 deletions hpx/runtime/threads/policies/periodic_priority_scheduler.hpp
Expand Up @@ -386,12 +386,21 @@ namespace hpx { namespace threads { namespace policies
return high_priority_queues_[num_thread]->get_thread_count(state);
break;
}

default:
case thread_priority_unknown:
{
HPX_THROW_EXCEPTION(bad_parameter,
"local_periodic_priority_scheduler::get_thread_count",
"unknown thread priority value (thread_priority_unknown)");
return 0;
}
}
}

// Return the cumulative count for all queues.
switch (priority) {
case thread_priority_default:
case thread_priority_default:
{
for (std::size_t i = 0; i < high_priority_queues_.size(); ++i)
result += high_priority_queues_[i]->get_thread_count(state);
Expand All @@ -402,7 +411,7 @@ namespace hpx { namespace threads { namespace policies
result += queues_[i]->get_thread_count(state);
}

case thread_priority_low:
case thread_priority_low:
return low_priority_queue_.get_thread_count(state);

case thread_priority_normal:
Expand All @@ -412,12 +421,21 @@ namespace hpx { namespace threads { namespace policies
break;
}

case thread_priority_critical:
case thread_priority_critical:
{
for (std::size_t i = 0; i < high_priority_queues_.size(); ++i)
result += high_priority_queues_[i]->get_thread_count(state);
break;
}

default:
case thread_priority_unknown:
{
HPX_THROW_EXCEPTION(bad_parameter,
"local_periodic_priority_scheduler::get_thread_count",
"unknown thread priority value (thread_priority_unknown)");
return 0;
}
}
return result;
}
Expand Down

0 comments on commit 526079b

Please sign in to comment.