00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef COMSTL_INCL_COMSTL_MEMORY_HPP_TASK_ALLOCATOR
00048 #define COMSTL_INCL_COMSTL_MEMORY_HPP_TASK_ALLOCATOR
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define COMSTL_VER_COMSTL_MEMORY_HPP_TASK_ALLOCATOR_MAJOR 4
00052 # define COMSTL_VER_COMSTL_MEMORY_HPP_TASK_ALLOCATOR_MINOR 0
00053 # define COMSTL_VER_COMSTL_MEMORY_HPP_TASK_ALLOCATOR_REVISION 4
00054 # define COMSTL_VER_COMSTL_MEMORY_HPP_TASK_ALLOCATOR_EDIT 87
00055 #endif
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #ifndef COMSTL_INCL_COMSTL_H_COMSTL
00070 # include <comstl/comstl.h>
00071 #endif
00072 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_ALLOCATOR_BASE
00073 # include <stlsoft/memory/allocator_base.hpp>
00074 #endif
00075
00076 #ifndef STLSOFT_INCL_NEW
00077 # define STLSOFT_INCL_NEW
00078 # include <new>
00079 #endif
00080
00081
00082
00083
00084
00085 #ifndef _COMSTL_NO_NAMESPACE
00086 # if defined(_STLSOFT_NO_NAMESPACE) || \
00087 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00088
00089 namespace comstl
00090 {
00091 # else
00092
00093
00094 namespace stlsoft
00095 {
00096
00097 namespace comstl_project
00098 {
00099
00100 # endif
00101 #endif
00102
00103
00104
00105
00106
00113 template <ss_typename_param_k T>
00114 class task_allocator
00115 : public allocator_base<T, task_allocator<T> >
00116 {
00117 private:
00118 typedef allocator_base<T, task_allocator<T> > parent_class_type;
00119 public:
00121 typedef task_allocator<T> class_type;
00123 typedef ss_typename_type_k parent_class_type::value_type value_type;
00125 typedef ss_typename_type_k parent_class_type::pointer pointer;
00127 typedef ss_typename_type_k parent_class_type::const_pointer const_pointer;
00129 typedef ss_typename_type_k parent_class_type::reference reference;
00131 typedef ss_typename_type_k parent_class_type::const_reference const_reference;
00133 typedef ss_typename_type_k parent_class_type::difference_type difference_type;
00135 typedef ss_typename_type_k parent_class_type::size_type size_type;
00136
00137 public:
00138 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00140 template <ss_typename_param_k U>
00141 struct rebind
00142 {
00143 typedef task_allocator<U> other;
00144 };
00145 #endif
00146
00149 public:
00151 task_allocator() stlsoft_throw_0()
00152 {}
00154 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00155 template <ss_typename_param_k U>
00156 task_allocator(task_allocator<U> const&)
00157 {}
00158 #else
00159 task_allocator(class_type const&)
00160 {}
00161 #endif
00163
00164 private:
00165 friend class allocator_base<T, task_allocator<T> >;
00166
00167 void *do_allocate(size_type n, void const* hint)
00168 {
00169 STLSOFT_SUPPRESS_UNUSED(hint);
00170
00171 return ::CoTaskMemAlloc(n * sizeof(value_type));
00172 }
00173 void do_deallocate(void *pv, size_type n)
00174 {
00175 STLSOFT_SUPPRESS_UNUSED(n);
00176
00177 ::CoTaskMemFree(pv);
00178 }
00179 void do_deallocate(void *pv)
00180 {
00181 ::CoTaskMemFree(pv);
00182 }
00183 };
00184
00185 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00186
00187
00188 STLSOFT_TEMPLATE_SPECIALISATION
00189 class task_allocator<void>
00190 {
00191 public:
00192 typedef void value_type;
00193 typedef task_allocator<void> class_type;
00194 typedef void* pointer;
00195 typedef void const* const_pointer;
00196 typedef cs_ptrdiff_t difference_type;
00197 typedef cs_size_t size_type;
00198
00199 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00201 template <ss_typename_param_k U>
00202 struct rebind
00203 {
00204 typedef task_allocator<U> other;
00205 };
00206 #endif
00207 };
00208
00209 #endif
00210
00211 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00212
00213 template <ss_typename_param_k T>
00214 inline cs_bool_t operator ==(const task_allocator<T> &, const task_allocator<T> &)
00215 {
00216 return cs_true_v;
00217 }
00218
00219 template <ss_typename_param_k T>
00220 inline cs_bool_t operator !=(const task_allocator<T> &, const task_allocator<T> &)
00221 {
00222 return cs_false_v;
00223 }
00224
00225 #endif
00226
00228
00229
00230 #ifdef STLSOFT_UNITTEST
00231 # include "./unittest/task_allocator_unittest_.h"
00232 #endif
00233
00234
00235
00236 #ifndef _COMSTL_NO_NAMESPACE
00237 # if defined(_STLSOFT_NO_NAMESPACE) || \
00238 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00239 }
00240 # else
00241 }
00242 }
00243 # endif
00244 #endif
00245
00246
00247
00248 #endif
00249
00250