shutdown_policies.hpp

来自「linux 环境下比较好的一个线程池实现源代码」· HPP 代码 · 共 84 行

HPP
84
字号
/*! \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 + =
减小字号Ctrl + -
显示快捷键?