root/experimental/NT-based/NTSpecific/thread_api_traits.hpp

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

INCLUDED FROM


   1 /******************************************************************************
   2 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/experimental/NT-based/NTSpecific/thread_api_traits.hpp 2055 2017-05-13 19:35:47Z jmmcg $
   3 **
   4 ** Copyright (c) 2004 by J.M.McGuiness, coder@hussar.me.uk
   5 **
   6 ** This library is free software; you can redistribute it and/or
   7 ** modify it under the terms of the GNU Lesser General Public
   8 ** License as published by the Free Software Foundation; either
   9 ** version 2.1 of the License, or (at your option) any later version.
  10 **
  11 ** This library is distributed in the hope that it will be useful,
  12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14 ** Lesser General Public License for more details.
  15 **
  16 ** You should have received a copy of the GNU Lesser General Public
  17 ** License along with this library; if not, write to the Free Software
  18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19 */
  20 
  21 namespace jmmcg {
  22 
  23         namespace NTUtils {
  24                 class win_exception;
  25         }
  26 
  27 namespace ppd {
  28 
  29         namespace NTUtils {
  30                 class recursive_anon_mutex;
  31                 class anon_event;
  32                 class recursive_critical_section;
  33                 class recursive_mutex;
  34                 class event;
  35                 class semaphore;
  36         }
  37 
  38         template<>
  39         struct api_lock_traits<generic_traits::MS_Win32, heavyweight_threading> {
  40                 static constexpr generic_traits::api_type api_type=generic_traits::MS_Win32;
  41                 typedef heavyweight_threading model_type;
  42                 enum atomic_state_type {
  43                         atom_set=WAIT_OBJECT_0,
  44                         atom_abandoned=WAIT_ABANDONED,
  45                         atom_already_set,
  46                         atom_max_recurse,
  47                         atom_deadlocked,
  48                         atom_perm_error,
  49                         atom_failed=WAIT_FAILED,
  50                         atom_interrupted,
  51                         atom_unset=WAIT_TIMEOUT,
  52                         atom_errno
  53                 };
  54 
  55                 typedef jmmcg::ppd::NTUtils::recursive_anon_mutex anon_mutex_type;
  56                 // TODO implement the non-recursive one.
  57                 typedef jmmcg::ppd::NTUtils::recursive_anon_mutex nonrecursive_anon_mutex_type;
  58                 typedef jmmcg::ppd::NTUtils::recursive_anon_mutex recursive_anon_mutex_type;
  59                 typedef jmmcg::ppd::NTUtils::anon_event anon_event_type;
  60                 typedef jmmcg::ppd::NTUtils::recursive_critical_section critical_section_type;
  61                 typedef jmmcg::ppd::NTUtils::recursive_critical_section recursive_critical_section_type;
  62                 typedef jmmcg::ppd::NTUtils::recursive_mutex mutex_type;
  63                 typedef jmmcg::ppd::NTUtils::recursive_mutex recursive_mutex_type;
  64                 typedef jmmcg::ppd::NTUtils::event event_type;
  65                 typedef jmmcg::ppd::NTUtils::anon_semaphore anon_semaphore_type;
  66                 typedef jmmcg::ppd::NTUtils::semaphore semaphore_type;
  67                 template<class V>
  68                 struct atomic_counter_type : atomic_ctr<V, api_lock_traits<api_type, model_type> > {
  69                         typedef atomic_ctr<V, api_lock_traits<api_type, model_type> > base_t;
  70                         typedef typename base_t::lock_traits lock_traits;
  71                         typedef typename base_t::atomic_t atomic_t;
  72                         typedef typename base_t::value_type value_type;
  73 
  74                         atomic_counter_type() : base_t() {}
  75                         explicit atomic_counter_type(const value_type v) : base_t(v) {}
  76                         atomic_counter_type(atomic_counter_type const &a) : base_t(a) {}
  77                         atomic_counter_type(base_t const &a) : base_t(a) {}
  78                 };
  79                 typedef HANDLE handle_type;
  80                 typedef DWORD timeout_type;
  81 
  82                 typedef jmmcg::NTUtils::win_exception exception_type;
  83 
  84                 static const timeout_type __fastcall infinite_timeout() noexcept(true) {
  85                         return static_cast<timeout_type>(INFINITE);
  86                 }
  87         };
  88 
  89         template<>
  90         struct api_threading_traits<generic_traits::api_type::no_api, sequential_mode> : api_threading_traits<generic_traits::MS_Win32, sequential_mode> {};
  91 
  92 } }
  93 
  94 #include "thread_api_traits_impl.hpp"

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