root/core/thread_pool_sequential.hpp

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. erase

   1 #ifndef libjmmcg_core_thread_pool_sequential_hpp
   2 #       define libjmmcg_core_thread_pool_sequential_hpp
   3 /******************************************************************************
   4 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/core/thread_pool_sequential.hpp 2055 2017-05-13 19:35:47Z jmmcg $
   5 **
   6 ** Copyright © 2004 by J.M.McGuiness, coder@hussar.me.uk
   7 **
   8 ** This library is free software; you can redistribute it and/or
   9 ** modify it under the terms of the GNU Lesser General Public
  10 ** License as published by the Free Software Foundation; either
  11 ** version 2.1 of the License, or (at your option) any later version.
  12 **
  13 ** This library is distributed in the hope that it will be useful,
  14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16 ** Lesser General Public License for more details.
  17 **
  18 ** You should have received a copy of the GNU Lesser General Public
  19 ** License along with this library; if not, write to the Free Software
  20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21 */
  22 
  23 #include "private_/thread_pool.hpp"
  24 
  25 namespace jmmcg {
  26 
  27         /// Parallel Pixie Dust or PPD is the name of the thread library within libjmmcg.
  28         /**
  29                 Why is it called "ppd"? It stands for "Parallel Pixie Dust", a term coined at the <a href="http://www.accu.org/">ACCU</a> by, if I recall correctly, Hubert Matthews in around 2001, whilst I was in conversation with him about thread libraries and their ability to shield a programmer from the issues of threading.
  30         */
  31         namespace ppd {
  32 
  33         /// This compatibility-pool has an unlimited size, and uses a master to execute the work.
  34         /**
  35                 There is no threading at all in this pool. It tries to be as fast as directly executing the methods
  36                 on the closure_base-derived closure class. The idea of this class is that you can use it to provide both single &
  37                 multi-threaded implementations within your objects and code, by just changing a typedef or a trait.
  38         */
  39         template<
  40                 class P
  41         >
  42         class thread_pool<pool_traits::work_distribution_mode_t::one_thread_distributes<>, pool_traits::size_mode_t::sequential, P>
  43         : public private_::sequential_pool<pool_traits::work_distribution_mode_t::one_thread_distributes<>, pool_traits::size_mode_t::sequential, P> {
  44         public:
  45                 typedef private_::sequential_pool<pool_traits::work_distribution_mode_t::one_thread_distributes<>, pool_traits::size_mode_t::sequential, P> base_t;
  46                 typedef typename base_t::api_params_type api_params_type;
  47         };
  48 
  49         /// This compatibility-pool has an unlimited size, and the "worker thread"s directly execute the work.
  50         /**
  51                 There is no threading at all in this pool. It tries to be as fast as directly executing the methods
  52                 on the closure_base-derived closure class. The idea of this class is that you can use it to provide both single &
  53                 multi-threaded implementations within your objects and code, by just changing a typedef or a trait.
  54         */
  55         template<
  56                 class P
  57         >
  58         class thread_pool<pool_traits::work_distribution_mode_t::worker_threads_get_work<pool_traits::work_distribution_mode_t::queue_model_t::pool_owns_queue>, pool_traits::size_mode_t::sequential, P>
  59         : public private_::sequential_pool<pool_traits::work_distribution_mode_t::worker_threads_get_work<pool_traits::work_distribution_mode_t::queue_model_t::pool_owns_queue>, pool_traits::size_mode_t::sequential, P> {
  60         public:
  61                 typedef private_::sequential_pool<pool_traits::work_distribution_mode_t::worker_threads_get_work<pool_traits::work_distribution_mode_t::queue_model_t::pool_owns_queue>, pool_traits::size_mode_t::sequential, P> base_t;
  62                 typedef typename base_t::os_traits os_traits;
  63                 typedef typename base_t::api_params_type api_params_type;
  64                 typedef typename base_t::pool_type pool_type;
  65                 typedef typename base_t::pool_size_type pool_size_type;
  66 
  67                 enum class erase_states {
  68                         failed_to_erase,
  69                         ignoring_result,
  70                         erased_successfully
  71                 };
  72 
  73                 constexpr __stdcall thread_pool() FORCE_INLINE
  74                 : base_t() {
  75                 }
  76                 explicit __stdcall thread_pool(const pool_size_type sz) FORCE_INLINE
  77                 : base_t(sz) {
  78                 }
  79 
  80                 template<typename ExecT>
  81                 static constexpr erase_states __fastcall FORCE_INLINE
  82                 erase(ExecT &) {
  83                         return erase_states::failed_to_erase;
  84                 }
  85         };
  86 
  87 } }
  88 
  89 #endif

/* [<][>][^][v][top][bottom][index][help] */