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

📄 task_adaptors.hpp

📁 threadpool is a cross-platform C++ thread pool library
💻 HPP
字号:
/*! \file * \brief Task adaptors. * * This file contains adaptors for task function objects. * * Copyright (c) 2005-2006 Philipp Henkel * * Distributed under 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_TASK_ADAPTERS_HPP_INCLUDED#define THREADPOOL_TASK_ADAPTERS_HPP_INCLUDED#include <boost/smart_ptr.hpp>#include "pool.hpp"namespace threadpool{/*! \brief Standard task function object. * * This function object wraps a function which gets no parameters and returns void. * The wrapped function is invoked by calling the operator (). * * \see boost function library * */ typedef boost::function0<void> thread_func;	/*! \brief Prioritized task function object.  * * This function object wraps a thread_func object and binds a priority to it. * prio_thread_funcs can be compared using the operator < which realises a partial ordering. * The wrapped task function is invoked by calling the operator (). * * \see prio_scheduler * */ class prio_thread_func{public:  /*! Constructor.   * \param priority The priority of the task.   * \param function The task's function object.   */  explicit prio_thread_func(unsigned int priority, thread_func function)  : m_priority(priority)  , m_function(function)  {  }  /*! Executes the task function.   */  void operator() (void) const  {    if(m_function)    {      m_function();    }  }  /*! Comparison operator which realises a partial ordering based on priorities.   * \param right The object to compare with.   * \return true if the priority of *this is less than right's priority, false otherwise.   */  bool operator< (const prio_thread_func& right) const  {    return m_priority < right.m_priority;   }private:  unsigned int m_priority;  //!< The priority of the task's function.  thread_func m_function;   //!< The task's function.};} // namespace threadpool#endif // THREADPOOL_TASK_ADAPTERS_HPP_INCLUDED

⌨️ 快捷键说明

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