// Client should exist but be stopped.
ASSERT_TRUE(service->client_);
ASSERT_TRUE(service->client_->isStopped());
+ EXPECT_TRUE(service->client_->getThreadIOService()->stopped());
- // Listener should exist but be stopped..
+ // Listener should exist but be stopped.
ASSERT_TRUE(service->listener_);
- ASSERT_TRUE(service->client_->isStopped());
+ ASSERT_TRUE(service->listener_->isStopped());
+ EXPECT_TRUE(service->listener_->getThreadIOService()->stopped());
// Start client and listener.
ASSERT_NO_THROW_LOG(service->startClientAndListener());
EXPECT_TRUE(service->client_->isRunning());
EXPECT_TRUE(service->client_->getThreadIOService());
EXPECT_EQ(service->client_->getThreadPoolSize(), scenario.exp_client_threads_);
+
// Currently thread count should be the same as thread pool size. This might
// change if we go to so some sort of dynamic thread instance management.
EXPECT_EQ(service->client_->getThreadCount(), scenario.exp_client_threads_);
// We should have a running listener with the expected number of threads.
ASSERT_TRUE(service->listener_);
EXPECT_TRUE(service->listener_->isRunning());
+ ASSERT_TRUE(service->listener_->getThreadIOService());
EXPECT_EQ(service->listener_->getThreadPoolSize(), scenario.exp_listener_threads_);
// Currently thread count should be the same as thread pool size. This might
/// \brief Stop the underlying event loop.
///
/// This will return the control to the caller of the \c run() method.
- void stop() { io_service_.stop();} ;
+ void stop() {
+ io_service_.stop();
+ }
/// \brief Indicates if the IOService has been stopped.
///
/// that share the same \c io_service with the authoritative server.
/// It will eventually be removed once the wrapper interface is
/// generalized.
- boost::asio::io_service& get_io_service() { return io_service_; };
+ boost::asio::io_service& get_io_service() {
+ return (io_service_);
+ }
/// \brief Post a callback on the IO service
///
const CallbackWrapper wrapper(callback);
io_service_.post(wrapper);
}
+
private:
boost::asio::io_service io_service_;
boost::shared_ptr<boost::asio::io_service::work> work_;
CmdHttpListener::CmdHttpListener(const IOAddress& address, const uint16_t port,
const uint16_t thread_pool_size /* = 1 */)
: address_(address), port_(port), thread_io_service_(), http_listener_(),
- thread_pool_size_(thread_pool_size), threads_() {
+ thread_pool_size_(thread_pool_size), thread_pool_() {
}
CmdHttpListener::~CmdHttpListener() {
// Create the HTTP listener. It will open up a TCP socket and be
// prepared to accept incoming connections.
TlsContextPtr tls_context;
- http_listener_.reset(new HttpListener(*thread_io_service_, address_, port_,
- tls_context, rcf,
+ http_listener_.reset(new HttpListener(*thread_io_service_, address_, port_, tls_context, rcf,
HttpListener::RequestTimeout(TIMEOUT_AGENT_RECEIVE_COMMAND),
HttpListener::IdleTimeout(TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT)));
// Create the thread pool with immediate start.
- threads_.reset(new HttpThreadPool(thread_io_service_, thread_pool_size_));
+ thread_pool_.reset(new HttpThreadPool(thread_io_service_, thread_pool_size_));
// Instruct the HTTP listener to actually open socket, install
// callback and start listening.
void
CmdHttpListener::pause() {
- if (threads_) {
- threads_->pause();
+ if (thread_pool_) {
+ thread_pool_->pause();
}
}
void
CmdHttpListener::resume() {
- if (threads_) {
- threads_->run();
+ if (thread_pool_) {
+ thread_pool_->run();
}
}
.arg(port_);
// Stop the thread pool.
- threads_->stop();
+ thread_pool_->stop();
// Get rid of the listener.
http_listener_.reset();
.arg(port_);
}
-HttpThreadPool::RunState
-CmdHttpListener::getRunState() const {
- if (!threads_) {
- isc_throw(InvalidOperation,
- "CmdHttpListener::getRunState - no thread pool!");
- }
-
- return (threads_->getRunState());
-}
-
bool
CmdHttpListener::isRunning() {
- if (threads_) {
- return (threads_->getRunState() == HttpThreadPool::RunState::RUNNING);
+ if (thread_pool_) {
+ return (thread_pool_->isRunning());
}
return (false);
bool
CmdHttpListener::isStopped() {
- if (threads_) {
- return (threads_->getRunState() == HttpThreadPool::RunState::STOPPED);
+ if (thread_pool_) {
+ return (thread_pool_->isStopped());
}
return (true);
bool
CmdHttpListener::isPaused() {
- if (threads_) {
- return (threads_->getRunState() == HttpThreadPool::RunState::PAUSED);
+ if (thread_pool_) {
+ return (thread_pool_->isPaused());
}
return (false);
/// @brief Stops the listener's thread pool.
void stop();
- /// @brief Fetches the run state of the thread pool.
+ /// @brief Indicates if the thread pool is running.
///
- /// @return Run state of the pool.
- http::HttpThreadPool::RunState getRunState() const;
-
- /// @brief Indicates if the thread pool processing is running.
- ///
- /// @return True if the thread pool exists and is in the RUN state,
+ /// @return True if the thread pool exists and is in the RUNNING state,
/// false otherwise.
bool isRunning();
///
/// @return uint16_t containing the number of running threads.
uint16_t getThreadCount() const {
- if (!threads_) {
+ if (!thread_pool_) {
return (0);
}
- return (threads_->getThreadCount());
+ return (thread_pool_->getThreadCount());
}
asiolink::IOServicePtr getThreadIOService() const {
std::size_t thread_pool_size_;
/// @brief The pool of threads that do IO work.
- http::HttpThreadPoolPtr threads_;
+ http::HttpThreadPoolPtr thread_pool_;
};
/// @brief Defines a shared pointer to CmdHttpListener.
ASSERT_FALSE(listener_->getThreadIOService());
EXPECT_TRUE(listener_->isStopped());
EXPECT_EQ(listener_->getThreadCount(), 0);
- ASSERT_THROW_MSG(listener_->getRunState(), InvalidOperation,
- "CmdHttpListener::getRunState - no thread pool!");
// Verify that we cannot start it when multi-threading is disabled.
ASSERT_FALSE(MultiThreadingMgr::instance().getMode());
EXPECT_EQ(listener_->getThreadCount(), 1);
ASSERT_TRUE(listener_->getThreadIOService());
EXPECT_FALSE(listener_->getThreadIOService()->stopped());
- EXPECT_EQ(listener_->getRunState(), HttpThreadPool::RunState::RUNNING);
+ EXPECT_TRUE(listener_->isRunning());
// Trying to start it again should fail.
ASSERT_THROW_MSG(listener_->start(), InvalidOperation,
ASSERT_NO_THROW_LOG(listener_->stop());
ASSERT_TRUE(listener_->isStopped());
EXPECT_EQ(listener_->getThreadCount(), 0);
- EXPECT_EQ(listener_->getRunState(), HttpThreadPool::RunState::STOPPED);
+ EXPECT_TRUE(listener_->isStopped());
ASSERT_FALSE(listener_->getThreadIOService());
// Make sure we can call stop again without problems.
ASSERT_TRUE(listener_->isStopped());
EXPECT_EQ(listener_->getThreadCount(), 0);
ASSERT_FALSE(listener_->getThreadIOService());
- EXPECT_EQ(listener_->getRunState(), HttpThreadPool::RunState::STOPPED);
+ EXPECT_TRUE(listener_->isStopped());
}
// This test verifies that an HTTP connection can be established and used to
/// is greater than zero.
HttpClientImpl(IOService& io_service, size_t thread_pool_size = 0,
bool defer_thread_start = false)
- : thread_pool_size_(thread_pool_size), threads_() {
+ : thread_pool_size_(thread_pool_size), thread_pool_() {
if (thread_pool_size_ > 0) {
// Create our own private IOService.
thread_io_service_.reset(new IOService());
// Create the thread pool.
- threads_.reset(new HttpThreadPool(thread_io_service_, thread_pool_size_,
- defer_thread_start));
+ thread_pool_.reset(new HttpThreadPool(thread_io_service_, thread_pool_size_,
+ defer_thread_start));
// Create the connection pool. Note that we use the thread_pool_size
// as the maximum connections per URL value.
/// @brief Starts client's thread pool, if multi-threaded.
void start() {
- if (threads_) {
- threads_->run();
+ if (thread_pool_) {
+ thread_pool_->run();
}
}
conn_pool_->closeAll();
// Stop the thread pool.
- if (threads_) {
- threads_->stop();
+ if (thread_pool_) {
+ thread_pool_->stop();
}
}
///
/// Suspends thread pool event processing.
void pause() {
- if (!threads_) {
+ if (!thread_pool_) {
isc_throw(InvalidOperation, "HttpClient::pause - no thread pool");
}
// Pause the thread pool.
- threads_->pause();
+ thread_pool_->pause();
}
/// @brief Resumes the thread pool operation.
///
/// Resumes thread pool event processing.
void resume() {
- if (!threads_) {
+ if (!thread_pool_) {
isc_throw(InvalidOperation, "HttpClient::resume - no thread pool");
}
// Resume running the thread pool.
- threads_->run();
- }
-
- /// @brief Fetches the thread pool's run state.
- ///
- /// @return Operational state of the thread pool.
- HttpThreadPool::RunState getRunState() const {
- if (!threads_) {
- isc_throw(InvalidOperation, "HttpClient::getRunState - no thread pool");
- }
-
- return (threads_->getRunState());
+ thread_pool_->run();
}
/// @brief Indicates if the thread pool processing is running.
/// @return True if the thread pool exists and is in the RUNNING state,
/// false otherwise.
bool isRunning() {
- if (threads_) {
- return (threads_->getRunState() == HttpThreadPool::RunState::RUNNING);
+ if (thread_pool_) {
+ return (thread_pool_->isRunning());
}
return (false);
/// @return True if the thread pool exists and is in the STOPPED state,
/// false otherwise
bool isStopped() {
- if (threads_) {
- return (threads_->getRunState() == HttpThreadPool::RunState::STOPPED);
+ if (thread_pool_) {
+ return (thread_pool_->isStopped());
}
return (false);
/// @return True if the thread pool exists and is in the PAUSED state,
/// false otherwise.
bool isPaused() {
- if (threads_) {
- return (threads_->getRunState() == HttpThreadPool::RunState::PAUSED);
+ if (thread_pool_) {
+ return (thread_pool_->isPaused());
}
return (false);
///
/// @return the number of running threads.
uint16_t getThreadCount() {
- if (!threads_) {
+ if (!thread_pool_) {
return (0);
}
- return (threads_->getThreadCount());
+ return (thread_pool_->getThreadCount());
}
/// @brief Holds a pointer to the connection pool.
/// @brief Pool of threads used to service connections in multi-threaded
/// mode.
- HttpThreadPoolPtr threads_;
+ HttpThreadPoolPtr thread_pool_;
};
HttpClient::HttpClient(IOService& io_service, size_t thread_pool_size,
return (impl_->getThreadCount());
}
-HttpThreadPool::RunState
-HttpClient::getRunState() const {
- return (impl_->getRunState());
-}
-
bool
HttpClient::isRunning() {
return (impl_->isRunning());
/// @return the number of running threads.
uint16_t getThreadCount() const;
- /// @brief Fetches the thread pool's run state.
- ///
- /// @return Operational state of the thread pool.
- /// @throw InvalidOperation if the thread pool does not exist.
- HttpThreadPool::RunState getRunState() const;
-
- /// @brief Indicates if the thread pool processing is running.
+ /// @brief Indicates if the thread pool is running.
///
/// @return True if the thread pool exists and is in the RUNNING state,
/// false otherwise.
HttpThreadPool::HttpThreadPool(IOServicePtr io_service, size_t pool_size,
bool defer_start /* = false */)
: pool_size_(pool_size), io_service_(io_service),
- run_state_(RunState::STOPPED), mutex_(), thread_cv_(),
+ run_state_(State::STOPPED), mutex_(), thread_cv_(),
main_cv_(), paused_(0), running_(0), exited_(0) {
if (!pool_size) {
isc_throw(BadValue, "HttpThreadPool::ctor pool_size must be > 0");
void
HttpThreadPool::run() {
- setRunState(RunState::RUNNING);
+ setState(State::RUNNING);
}
void
HttpThreadPool::pause() {
- setRunState(RunState::PAUSED);
+ setState(State::PAUSED);
}
void
HttpThreadPool::stop() {
- setRunState(RunState::STOPPED);
+ setState(State::STOPPED);
}
-HttpThreadPool::RunState
-HttpThreadPool::getRunState() {
+HttpThreadPool::State
+HttpThreadPool::getState() {
std::lock_guard<std::mutex> lck(mutex_);
return (run_state_);
}
bool
-HttpThreadPool::validateStateChange(RunState new_state) const {
+HttpThreadPool::validateStateChange(State new_state) const {
bool is_valid = false;
switch(run_state_) {
- case RunState::STOPPED:
- is_valid = (new_state == RunState::RUNNING);
+ case State::STOPPED:
+ is_valid = (new_state == State::RUNNING);
break;
- case RunState::RUNNING:
- is_valid = (new_state != RunState::RUNNING);
+ case State::RUNNING:
+ is_valid = (new_state != State::RUNNING);
break;
- case RunState::PAUSED:
- is_valid = (new_state != RunState::PAUSED);
+ case State::PAUSED:
+ is_valid = (new_state != State::PAUSED);
break;
}
}
void
-HttpThreadPool::setRunState (RunState new_state) {
+HttpThreadPool::setState(State new_state) {
std::unique_lock<std::mutex> main_lck(mutex_);
// Bail if the transition is invalid.
thread_cv_.notify_all();
switch(new_state) {
- case RunState::RUNNING: {
+ case State::RUNNING: {
// Restart the IOService.
io_service_->restart();
break;
}
- case RunState::PAUSED: {
+ case State::PAUSED: {
// Stop IOService.
if (!io_service_->stopped()) {
io_service_->poll();
break;
}
- case RunState::STOPPED: {
+ case State::STOPPED: {
// Stop IOService.
if (!io_service_->stopped()) {
io_service_->poll();
HttpThreadPool::threadWork() {
bool done = false;
while (!done) {
- switch (getRunState()) {
- case RunState::RUNNING: {
+ switch (getState()) {
+ case State::RUNNING: {
{
std::unique_lock<std::mutex> lck(mutex_);
running_++;
break;
}
- case RunState::PAUSED: {
+ case State::PAUSED: {
std::unique_lock<std::mutex> lck(mutex_);
paused_++;
// Wait here till I'm released.
thread_cv_.wait(lck,
[&]() {
- return (run_state_ != RunState::PAUSED);
+ return (run_state_ != State::PAUSED);
});
paused_--;
break;
}
- case RunState::STOPPED: {
+ case State::STOPPED: {
done = true;
break;
}}
/// @brief Implements a pausable pool of IOService driven threads.
class HttpThreadPool {
public:
- /// @brief Describes the possible operational state of the pool.
- enum class RunState {
+ /// @brief Describes the possible operational state of the thread pool.
+ enum class State {
STOPPED, /// Pool is not operational.
RUNNING, /// Pool is populated with running threads.
PAUSED, /// Pool is populated with threads that are paused.
/// @brief Destructor
///
- /// Ensures the pool is stopped prior to destruction.
+ /// Ensures the thread pool is stopped prior to destruction.
~HttpThreadPool();
/// @brief Transitions the pool from STOPPED or PAUSED to RUNNING.
///
- /// When called from the STOPPED state, the pool threads are created
+ /// When called from the STOPPED state, the pool threads are created and
/// begin processing events.
/// When called from the PAUSED state, the pool threads are released
- /// from PAUSED and resume processing event.s
+ /// from PAUSED and resume processing events.
/// Has no effect if the pool is already in the RUNNING state.
void run();
- /// @brief Transitions the pool from RUNNING to PAUSED state.
+ /// @brief Transitions the pool from RUNNING to PAUSED.
///
/// Pool threads suspend event processing and pause until they
/// are released to either resume running or stop.
/// Has no effect if the pool is already in the STOPPED state.
void stop();
- /// @brief Thread-safe fetch of the pool's operational state.
+ /// @brief Check if the thread pool is running.
+ ///
+ /// @return True if the thread pool is running, false otherwise.
+ bool isRunning() {
+ return (getState() == State::RUNNING);
+ }
+
+ /// @brief Check if the thread pool is paused.
+ ///
+ /// @return True if the thread pool is paused, false otherwise.
+ bool isPaused() {
+ return (getState() == State::PAUSED);
+ }
+
+ /// @brief Check if the thread pool is stopped.
///
- /// @return Pool run state.
- RunState getRunState();
+ /// @return True if the thread pool is stopped, false otherwise.
+ bool isStopped() {
+ return (getState() == State::STOPPED);
+ }
private:
/// @brief Thread-safe change of the pool's run state.
/// -# Notifies threads of state change.
/// -# Restarts the IOService.
/// -# Creates the threads if they do not yet exist (true only
- /// when transitioning from STOPPED).
+ /// when transitioning from STOPPED).
/// -# Waits until threads are running.
/// -# Sets the count of exited threads to 0.
/// -# Returns to caller.
/// -# Returns to caller.
///
/// @param state new state for the pool.
- void setRunState(RunState state);
+ void setState(State state);
+
+ /// @brief Thread-safe fetch of the pool's operational state.
+ ///
+ /// @return Thread pool state.
+ State getState();
/// @brief Validates whether the pool can change to a given state.
///
/// @param state new state for the pool.
- /// @return true if the Chang's is valid, false otherwise.
+ /// @return true if the change is valid, false otherwise.
/// @note Must be called from a thread-safe context.
- bool validateStateChange(RunState state) const;
+ bool validateStateChange(State state) const;
/// @brief Work function executed by each thread in the pool.
///
asiolink::IOServicePtr io_service_;
/// @brief Tracks the operational state of the pool.
- RunState run_state_;
+ State run_state_;
/// @brief Mutex to protect the internal state.
std::mutex mutex_;
/// @brief Pool of threads used to service connections in multi-threaded
/// mode.
std::list<boost::shared_ptr<std::thread> > threads_;
-
};
/// @brief Defines a pointer to a thread pool.
} // end of namespace isc
#endif
-
// IOService should be there.
// IOService is new, so it should not be stopped,
// No threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
EXPECT_EQ(pool->getPoolSize(), 3);
ASSERT_TRUE(pool->getIOService());
EXPECT_FALSE(pool->getIOService()->stopped());
// Pool size should be 3, state should be RUNNING, IOService should
// set but not stopped, and we should have 3 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
EXPECT_EQ(pool->getPoolSize(), 3);
ASSERT_TRUE(pool->getIOService());
EXPECT_FALSE(pool->getIOService()->stopped());
// Create a stopped pool.
ASSERT_NO_THROW_LOG(pool.reset(new HttpThreadPool(io_service_, 3, true)));
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
// Call run from STOPPED.
ASSERT_NO_THROW_LOG(pool->run());
// State should be RUNNING, IOService should not be stopped, we should
// have 3 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
EXPECT_FALSE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 3);
// State should be RUNNING, IOService should not be stopped, we should
// have 3 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
EXPECT_FALSE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 3);
// Create a running pool.
ASSERT_NO_THROW_LOG(pool.reset(new HttpThreadPool(io_service_, 3, false)));
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
// Call stop.
ASSERT_NO_THROW_LOG(pool->stop());
// State should be STOPPED, IOService should be stopped, we should
// have 0 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
EXPECT_TRUE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 0);
// State should be STOPPED, IOService should be stopped, we should
// have 0 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
EXPECT_TRUE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 0);
// Create a running pool.
ASSERT_NO_THROW_LOG(pool.reset(new HttpThreadPool(io_service_, 3, false)));
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
// Call pause from RUNNING.
ASSERT_NO_THROW_LOG(pool->pause());
// State should be PAUSED, IOService should be stopped, we should
// have 3 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::PAUSED, pool->getRunState());
+ ASSERT_TRUE(pool->isPaused());
EXPECT_TRUE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 3);
// State should be PAUSED, IOService should be stopped, we should
// have 3 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::PAUSED, pool->getRunState());
+ ASSERT_TRUE(pool->isPaused());
EXPECT_TRUE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 3);
// Create a running pool.
ASSERT_NO_THROW_LOG(pool.reset(new HttpThreadPool(io_service_, 3, false)));
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
// Call pause from RUNNING.
ASSERT_NO_THROW_LOG(pool->pause());
- ASSERT_EQ(HttpThreadPool::RunState::PAUSED, pool->getRunState());
+ ASSERT_TRUE(pool->isPaused());
// Call run.
ASSERT_NO_THROW_LOG(pool->run());
// State should be RUNNING, IOService should not be stopped, we should
// have 3 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
EXPECT_FALSE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 3);
// Create a running pool.
ASSERT_NO_THROW_LOG(pool.reset(new HttpThreadPool(io_service_, 3, false)));
- ASSERT_EQ(HttpThreadPool::RunState::RUNNING, pool->getRunState());
+ ASSERT_TRUE(pool->isRunning());
// Call pause from RUNNING.
ASSERT_NO_THROW_LOG(pool->pause());
- ASSERT_EQ(HttpThreadPool::RunState::PAUSED, pool->getRunState());
+ ASSERT_TRUE(pool->isPaused());
// Call stop.
ASSERT_NO_THROW_LOG(pool->stop());
// State should be STOPPED, IOService should be stopped, we should
// have 0 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
EXPECT_TRUE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 0);
// Create a stopped pool.
ASSERT_NO_THROW_LOG(pool.reset(new HttpThreadPool(io_service_, 3, true)));
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
// State should be STOPPED, IOService won't be stopped because it was
// never started. We should have 0 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
EXPECT_FALSE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 0);
ASSERT_NO_THROW_LOG(pool->pause());
// Should have no effect.
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
// State should be STOPPED, IOService won't be stopped because it was
// never started. We should have 0 threads in the pool.
- ASSERT_EQ(HttpThreadPool::RunState::STOPPED, pool->getRunState());
+ ASSERT_TRUE(pool->isStopped());
EXPECT_FALSE(pool->getIOService()->stopped());
EXPECT_EQ(pool->getThreadCount(), 0);
// Verify that it has an internal IOService and that thread pool size
// and thread count match.
ASSERT_TRUE(client->getThreadIOService());
+ EXPECT_FALSE(client->getThreadIOService()->stopped());
ASSERT_EQ(client->getThreadPoolSize(), 3);
ASSERT_EQ(client->getThreadCount(), 3);
- ASSERT_EQ(client->getRunState(), HttpThreadPool::RunState::RUNNING);
// Check convenience functions.
ASSERT_TRUE(client->isRunning());
ASSERT_TRUE(client->getThreadIOService());
ASSERT_EQ(client->getThreadPoolSize(), thread_pool_size);
ASSERT_EQ(client->getThreadCount(), 0);
- ASSERT_EQ(client->getRunState(), HttpThreadPool::RunState::STOPPED);
// Check convenience functions.
ASSERT_FALSE(client->isRunning());
ASSERT_EQ(client->getThreadCount(), 3);
ASSERT_TRUE(client->getThreadIOService());
ASSERT_FALSE(client->getThreadIOService()->stopped());
- ASSERT_EQ(client->getRunState(), HttpThreadPool::RunState::RUNNING);
// Check convenience functions.
ASSERT_TRUE(client->isRunning());
// Verify we didn't break it.
ASSERT_EQ(client->getThreadCount(), 3);
- ASSERT_EQ(client->getRunState(), HttpThreadPool::RunState::RUNNING);
+ ASSERT_TRUE(client->isRunning());
// Make sure destruction doesn't throw.
ASSERT_NO_THROW_LOG(client.reset());
ASSERT_EQ(client->getThreadCount(), 3);
ASSERT_TRUE(client->getThreadIOService());
ASSERT_FALSE(client->getThreadIOService()->stopped());
- ASSERT_EQ(client->getRunState(), HttpThreadPool::RunState::RUNNING);
+ ASSERT_TRUE(client->isRunning());
// Stop should succeed.
ASSERT_NO_THROW_LOG(client->stop());
ASSERT_EQ(client->getThreadCount(), 0);
ASSERT_TRUE(client->getThreadIOService());
ASSERT_TRUE(client->getThreadIOService()->stopped());
- ASSERT_EQ(client->getRunState(), HttpThreadPool::RunState::STOPPED);
+ ASSERT_TRUE(client->isStopped());
// Starting again should succeed.
ASSERT_NO_THROW_LOG(client->start());
ASSERT_EQ(client->getThreadCount(), 3);
ASSERT_TRUE(client->getThreadIOService());
ASSERT_FALSE(client->getThreadIOService()->stopped());
- ASSERT_EQ(client->getRunState(), HttpThreadPool::RunState::RUNNING);
+ ASSERT_TRUE(client->isRunning());
// Make sure destruction doesn't throw.
ASSERT_NO_THROW_LOG(client.reset());