/// @c MultiThreadingCriticalSection body.
/// @note: starting and stopping the packet thread pool should be handled
/// in the main thread, if done on one of the processing threads will cause a
-/// deadlock
+/// deadlock.
/// This is mainly useful in hook commands which handle configuration
/// changes.
class MultiThreadingCriticalSection : public boost::noncopyable {
/// @brief Constructor.
///
/// Entering the critical section. The packet thread pool instance will be
- /// stopped so that configuration changes can be safely applied.
+ /// stopped so that all configuration changes can be safely applied.
MultiThreadingCriticalSection();
/// @brief Destructor.
///
/// Leaving the critical section. The packet thread pool instance will be
- /// started according to new configuration.
+ /// started according to the new configuration.
virtual ~MultiThreadingCriticalSection();
private:
// thread count should match
EXPECT_EQ(thread_pool.size(), 64);
// apply multi-threading configuration with 0 threads
- MultiThreadingMgr::instance().apply(false, 64);
- // thread pool should be stopped
- EXPECT_EQ(thread_pool.size(), 0);
+ MultiThreadingMgr::instance().apply(false, 0);
}
} // namespace
/// @param enabled The new mode.
void setMode(bool enabled);
- /// @brief Increment override
+ /// @brief Increment override.
///
/// When entering @ref MultiThreadingCriticalSection, increment override
/// so that any configuration change that might start the packet thread pool
- /// is delayed until exiting the respective section
+ /// is delayed until exiting the respective section.
void incrementOverride();
- /// @brief Decrement override
+ /// @brief Decrement override.
///
/// When exiting @ref MultiThreadingCriticalSection, decrement override
- /// so that the packet thread pool can be started according to configuration
+ /// so that the packet thread pool can be started according to the new
+ /// configuration.
void decrementOverride();
- /// @brief Get override
+ /// @brief Get override.
///
- /// Get the override flag
+ /// Get the override flag.
bool getOverride();
/// @brief Get the packet thread pool.
/// @return The thread count.
static uint32_t supportedThreadCount();
- /// @brief Apply the multi-threading related settings
+ /// @brief Apply the multi-threading related settings.
///
/// @param enabled The enabled flag: true if multi-threading is enabled,
/// false otherwise.
///
/// In case the configuration is applied within a
/// @ref MultiThreadingCriticalSection, the thread pool should not be
- /// started until the section is over.
+ /// started until leaving the respective section.
/// This also handles multiple interleaved sections.
uint32_t override_;