ReactOS 0.4.15-dev-7934-g1dc8d80
per_thread_allocator< _Tp > Class Template Reference

#include <_pthread_alloc.h>

Public Types

typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef _Tp * pointer
 
typedef const _Tp * const_pointer
 
typedef _Tp & reference
 
typedef const _Tp & const_reference
 
typedef _Tp value_type
 

Public Member Functions

 per_thread_allocator () _STLP_NOTHROW
 
 per_thread_allocator (const per_thread_allocator< _Tp > &__a) _STLP_NOTHROW
 
 ~per_thread_allocator () _STLP_NOTHROW
 
pointer address (reference __x) const
 
const_pointer address (const_reference __x) const
 
_Tp * allocate (size_type __n, const void *=0)
 
void deallocate (pointer __p, size_type __n)
 
size_type max_size () const _STLP_NOTHROW
 
void construct (pointer __p, const _Tp &__val)
 
void destroy (pointer _p)
 
_Tp * allocate (size_type __n, size_type &__allocated_n)
 

Public Attributes

__state_type_M_state
 

Private Types

typedef pthread_alloc _S_Alloc
 
typedef pthread_alloc::__state_type __state_type
 

Detailed Description

template<class _Tp>
class per_thread_allocator< _Tp >

Definition at line 277 of file _pthread_alloc.h.

Member Typedef Documentation

◆ __state_type

template<class _Tp >
typedef pthread_alloc::__state_type per_thread_allocator< _Tp >::__state_type
private

Definition at line 279 of file _pthread_alloc.h.

◆ _S_Alloc

template<class _Tp >
typedef pthread_alloc per_thread_allocator< _Tp >::_S_Alloc
private

Definition at line 278 of file _pthread_alloc.h.

◆ const_pointer

template<class _Tp >
typedef const _Tp* per_thread_allocator< _Tp >::const_pointer

Definition at line 284 of file _pthread_alloc.h.

◆ const_reference

template<class _Tp >
typedef const _Tp& per_thread_allocator< _Tp >::const_reference

Definition at line 286 of file _pthread_alloc.h.

◆ difference_type

template<class _Tp >
typedef ptrdiff_t per_thread_allocator< _Tp >::difference_type

Definition at line 282 of file _pthread_alloc.h.

◆ pointer

template<class _Tp >
typedef _Tp* per_thread_allocator< _Tp >::pointer

Definition at line 283 of file _pthread_alloc.h.

◆ reference

template<class _Tp >
typedef _Tp& per_thread_allocator< _Tp >::reference

Definition at line 285 of file _pthread_alloc.h.

◆ size_type

template<class _Tp >
typedef size_t per_thread_allocator< _Tp >::size_type

Definition at line 281 of file _pthread_alloc.h.

◆ value_type

template<class _Tp >
typedef _Tp per_thread_allocator< _Tp >::value_type

Definition at line 287 of file _pthread_alloc.h.

Constructor & Destructor Documentation

◆ per_thread_allocator() [1/2]

template<class _Tp >
per_thread_allocator< _Tp >::per_thread_allocator ( )
inline

Definition at line 295 of file _pthread_alloc.h.

295 {
296 _M_state = _S_Alloc::_S_get_per_thread_state();
297 }
__state_type * _M_state

◆ per_thread_allocator() [2/2]

template<class _Tp >
per_thread_allocator< _Tp >::per_thread_allocator ( const per_thread_allocator< _Tp > &  __a)
inline

Definition at line 298 of file _pthread_alloc.h.

298: _M_state(__a._M_state){}

◆ ~per_thread_allocator()

template<class _Tp >
per_thread_allocator< _Tp >::~per_thread_allocator ( )
inline

Definition at line 305 of file _pthread_alloc.h.

305{}

Member Function Documentation

◆ address() [1/2]

template<class _Tp >
const_pointer per_thread_allocator< _Tp >::address ( const_reference  __x) const
inline

Definition at line 308 of file _pthread_alloc.h.

308{ return &__x; }

◆ address() [2/2]

template<class _Tp >
pointer per_thread_allocator< _Tp >::address ( reference  __x) const
inline

Definition at line 307 of file _pthread_alloc.h.

307{ return &__x; }

◆ allocate() [1/2]

template<class _Tp >
_Tp * per_thread_allocator< _Tp >::allocate ( size_type  __n,
const void = 0 
)
inline

Definition at line 312 of file _pthread_alloc.h.

312 {
313 if (__n > max_size()) {
315 }
316 if (__n != 0) {
317 size_type __buf_size = __n * sizeof(value_type);
318 _Tp* __ret = __REINTERPRET_CAST(_Tp*, _S_Alloc::allocate(__buf_size, _M_state));
319#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
320 memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
321#endif
322 return __ret;
323 }
324 else
325 return 0;
326 }
return __n
Definition: _algo.h:75
#define _STLP_THROW_BAD_ALLOC
Definition: _new.h:116
size_type max_size() const _STLP_NOTHROW
#define __REINTERPRET_CAST(__x, __y)
Definition: features.h:586
#define _STLP_SHRED_BYTE
Definition: features.h:903
#define memset(x, y, z)
Definition: compat.h:39

◆ allocate() [2/2]

template<class _Tp >
_Tp * per_thread_allocator< _Tp >::allocate ( size_type  __n,
size_type __allocated_n 
)
inline

Definition at line 354 of file _pthread_alloc.h.

354 {
355 if (__n > max_size()) {
357 }
358 if (__n != 0) {
359 size_type __buf_size = __n * sizeof(value_type);
360 _Tp* __ret = __REINTERPRET_CAST(value_type*, _S_Alloc::allocate(__buf_size, _M_state));
361#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
362 memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
363#endif
364 __allocated_n = __buf_size / sizeof(value_type);
365 return __ret;
366 }
367 else
368 return 0;
369 }

◆ construct()

template<class _Tp >
void per_thread_allocator< _Tp >::construct ( pointer  __p,
const _Tp &  __val 
)
inline

Definition at line 341 of file _pthread_alloc.h.

341{ new(__p) _Tp(__val); }
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656

◆ deallocate()

template<class _Tp >
void per_thread_allocator< _Tp >::deallocate ( pointer  __p,
size_type  __n 
)
inline

Definition at line 328 of file _pthread_alloc.h.

328 {
329 _STLP_ASSERT( (__p == 0) == (__n == 0) )
330 if (__p != 0) {
331#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
332 memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type));
333#endif
334 _S_Alloc::deallocate(__p, __n * sizeof(value_type), _M_state);
335 }
336 }
#define _STLP_ASSERT(expr)
Definition: _debug.h:165
if(dx< 0)
Definition: linetemp.h:194

◆ destroy()

template<class _Tp >
void per_thread_allocator< _Tp >::destroy ( pointer  _p)
inline

Definition at line 342 of file _pthread_alloc.h.

342{ _p->~_Tp(); }

◆ max_size()

template<class _Tp >
size_type per_thread_allocator< _Tp >::max_size ( ) const
inline

Definition at line 338 of file _pthread_alloc.h.

339 { return size_t(-1) / sizeof(_Tp); }
__kernel_size_t size_t
Definition: linux.h:237

Referenced by per_thread_allocator< _Tp >::allocate().

Member Data Documentation

◆ _M_state


The documentation for this class was generated from the following file: