/*
This file is a part of libcds - Concurrent Data Structures library
- (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
#include <cds/details/allocator.h>
#include <cds/intrusive/vyukov_mpmc_cycle_queue.h>
+#include <cds/details/throw_exception.h>
namespace cds { namespace memory {
//@cond
void preallocate_pool()
{
- m_pFirst = std_allocator().allocate( m_Queue.capacity() );
+ m_pFirst = std_allocator().allocate( m_Queue.capacity());
m_pLast = m_pFirst + m_Queue.capacity();
for ( value_type * p = m_pFirst; p < m_pLast; ++p ) {
value_type * p = m_Queue.pop();
if ( p ) {
- assert( from_pool(p) );
+ assert( from_pool(p));
return new( p ) value_type;
}
// The pool is empty - allocate new from the heap
CDS_UNUSED(n);
if ( p ) {
- if ( from_pool(p) ) {
+ if ( from_pool(p)) {
p->~value_type();
// The queue can notify about false fullness state
// so we push in loop
~lazy_vyukov_queue_pool()
{
std_allocator a;
- while ( !m_Queue.empty() )
+ while ( !m_Queue.empty())
a.deallocate( m_Queue.pop(), 1 );
}
if ( !p ) {
back_off bkoff;
- while ( m_Queue.size() ) {
+ while ( m_Queue.size()) {
p = m_Queue.pop();
if ( p )
goto ok;
}
// The pool is empty
- throw std::bad_alloc();
+ CDS_THROW_EXCEPTION( std::bad_alloc());
}
ok:
- assert( from_pool(p) );
+ assert( from_pool(p));
return p;
}
back_off bkoff;
// The queue can notify it is full but that is false fullness state
// So, we push in loop
- while ( !m_Queue.push(*p) )
+ while ( !m_Queue.push(*p))
bkoff();
}
}