⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shutdown_policies.hpp

📁 linux 环境下比较好的一个线程池实现源代码
💻 HPP
字号:
/*! \file* \brief Shutdown policies.** This file contains shutdown policies for thread_pool. * A shutdown policy controls the pool's behavior from the time* when the pool is not referenced any longer.** Copyright (c) 2005-2007 Philipp Henkel** Use, modification, and distribution are  subject to the* Boost Software License, Version 1.0. (See accompanying  file* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)** http://threadpool.sourceforge.net**/#ifndef THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED#define THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED/// The namespace threadpool contains a thread pool and related utility classes.namespace boost { namespace threadpool{/*! \brief ShutdownPolicy which waits for the completion of all tasks   *          and the worker termination afterwards.    *  * \param Pool The pool's core type.  */   template<typename Pool>  class wait_for_all_tasks  {  public:    static void shutdown(Pool& pool)    {      pool.wait();      pool.terminate_all_workers(true);    }  };  /*! \brief ShutdownPolicy which waits for the completion of all active tasks   *          and the worker termination afterwards.  *  * \param Pool The pool's core type.  */   template<typename Pool>  class wait_for_active_tasks  {  public:    static void shutdown(Pool& pool)    {      pool.clear();      pool.wait();      pool.terminate_all_workers(true);    }  };  /*! \brief ShutdownPolicy which does not wait for any tasks or worker termination.  *  * This policy does not wait for any tasks. Nevertheless all active tasks will be processed completely.  *  * \param Pool The pool's core type.  */   template<typename Pool>  class immediately  {  public:    static void shutdown(Pool& pool)    {      pool.clear();      pool.terminate_all_workers(false);    }  };} } // namespace boost::threadpool#endif // THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -