libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
thread_api_traits.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2004 by J.M.McGuiness, coder@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 namespace jmmcg { namespace LIBJMMCG_VER_NAMESPACE {
20 
21  namespace NTUtils {
22  class win_exception;
23  }
24 
25 namespace ppd {
26 
27  namespace NTUtils {
28  class recursive_anon_mutex;
29  class anon_event;
30  class recursive_critical_section;
31  class recursive_mutex;
32  class event;
33  class semaphore;
34  }
35 
36  template<>
37  struct api_lock_traits<generic_traits::MS_Win32, heavyweight_threading> {
38  static constexpr generic_traits::api_type api_type=generic_traits::MS_Win32;
51  };
52 
53  typedef ppd::NTUtils::recursive_anon_mutex anon_mutex_type;
54  // TODO implement the non-recursive one.
55  typedef ppd::NTUtils::recursive_anon_mutex nonrecursive_anon_mutex_type;
56  typedef ppd::NTUtils::recursive_anon_mutex recursive_anon_mutex_type;
57  typedef ppd::NTUtils::anon_event anon_event_type;
58  typedef ppd::NTUtils::recursive_critical_section critical_section_type;
59  typedef ppd::NTUtils::recursive_critical_section recursive_critical_section_type;
60  typedef ppd::NTUtils::recursive_mutex mutex_type;
61  typedef ppd::NTUtils::recursive_mutex recursive_mutex_type;
62  typedef ppd::NTUtils::event event_type;
64  typedef ppd::NTUtils::semaphore semaphore_type;
65  template<class V>
68  typedef typename base_t::lock_traits lock_traits;
69  typedef typename base_t::atomic_t atomic_t;
70  typedef typename base_t::value_type value_type;
71 
73  explicit atomic_counter_type(const value_type v) : base_t(v) {}
75  atomic_counter_type(base_t const &a) : base_t(a) {}
76  };
79 
81 
82  static const timeout_type __fastcall infinite_timeout() noexcept(true) {
83  return static_cast<timeout_type>(INFINITE);
84  }
85  };
86 
87  template<>
88  struct api_threading_traits<generic_traits::api_type::no_api, sequential_mode> : api_threading_traits<generic_traits::MS_Win32, sequential_mode> {};
89 
90 } } }
91