end = arguments[1];
increment = arguments[2];
break;
+ default:
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid number of arguments for range()"));
}
Array::Ptr result = make_shared<Array>();
int ThreadPool::m_NextID = 1;
-ThreadPool::ThreadPool(int max_threads)
+ThreadPool::ThreadPool(size_t max_threads)
: m_ID(m_NextID++), m_MaxThreads(max_threads), m_Stopped(false)
{
- if (m_MaxThreads != -1 && m_MaxThreads < sizeof(m_Queues) / sizeof(m_Queues[0]))
+ if (m_MaxThreads != UINT_MAX && m_MaxThreads < sizeof(m_Queues) / sizeof(m_Queues[0]))
m_MaxThreads = sizeof(m_Queues) / sizeof(m_Queues[0]);
Start();
break;
}
- for (int i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++) {
+ for (size_t i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++) {
size_t pending, alive = 0;
double avg_latency;
double utilization = 0;
if (tthreads > 0 && pending > 0)
tthreads = 8;
- if (m_MaxThreads != -1 && (alive + tthreads) * (sizeof(m_Queues) / sizeof(m_Queues[0])) > m_MaxThreads)
+ if (m_MaxThreads != UINT_MAX && (alive + tthreads) * (sizeof(m_Queues) / sizeof(m_Queues[0])) > m_MaxThreads)
tthreads = m_MaxThreads / (sizeof(m_Queues) / sizeof(m_Queues[0])) - alive;
if (tthreads != 0) {
utilization = 1;
break;
default:
- ASSERT(0);
+ VERIFY(0);
}
double now = Utility::GetTime();
public:
typedef boost::function<void ()> WorkFunction;
- ThreadPool(int max_threads = -1);
+ ThreadPool(size_t max_threads = UINT_MAX);
~ThreadPool(void);
void Start(void);
int m_ID;
static int m_NextID;
- unsigned int m_MaxThreads;
+ size_t m_MaxThreads;
boost::thread_group m_ThreadGroup;