projects
/
libcds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactors queue push pop
[libcds.git]
/
cds
/
memory
/
vyukov_queue_pool.h
diff --git
a/cds/memory/vyukov_queue_pool.h
b/cds/memory/vyukov_queue_pool.h
index 9821a89236bbe9e4023414dd2cf39ccbb51d19b7..432a7f02d9aeaeeabb68547c65788dd9e5943ff2 100644
(file)
--- a/
cds/memory/vyukov_queue_pool.h
+++ b/
cds/memory/vyukov_queue_pool.h
@@
-1,7
+1,7
@@
/*
This file is a part of libcds - Concurrent Data Structures library
/*
This file is a part of libcds - Concurrent Data Structures library
- (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-201
6
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-201
7
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
@@
-33,6
+33,7
@@
#include <cds/details/allocator.h>
#include <cds/intrusive/vyukov_mpmc_cycle_queue.h>
#include <cds/details/allocator.h>
#include <cds/intrusive/vyukov_mpmc_cycle_queue.h>
+#include <cds/details/throw_exception.h>
namespace cds { namespace memory {
namespace cds { namespace memory {
@@
-135,7
+136,7
@@
namespace cds { namespace memory {
//@cond
void preallocate_pool()
{
//@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 ) {
m_pLast = m_pFirst + m_Queue.capacity();
for ( value_type * p = m_pFirst; p < m_pLast; ++p ) {
@@
-184,7
+185,7
@@
namespace cds { namespace memory {
value_type * p = m_Queue.pop();
if ( 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
return new( p ) value_type;
}
// The pool is empty - allocate new from the heap
@@
-205,7
+206,7
@@
namespace cds { namespace memory {
CDS_UNUSED(n);
if ( p ) {
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
p->~value_type();
// The queue can notify about false fullness state
// so we push in loop
@@
-309,7
+310,7
@@
namespace cds { namespace memory {
~lazy_vyukov_queue_pool()
{
std_allocator a;
~lazy_vyukov_queue_pool()
{
std_allocator a;
- while ( !m_Queue.empty()
)
+ while ( !m_Queue.empty())
a.deallocate( m_Queue.pop(), 1 );
}
a.deallocate( m_Queue.pop(), 1 );
}
@@
-502,7
+503,7
@@
namespace cds { namespace memory {
if ( !p ) {
back_off bkoff;
if ( !p ) {
back_off bkoff;
- while ( m_Queue.size()
) {
+ while ( m_Queue.size()) {
p = m_Queue.pop();
if ( p )
goto ok;
p = m_Queue.pop();
if ( p )
goto ok;
@@
-510,11
+511,11
@@
namespace cds { namespace memory {
}
// The pool is empty
}
// The pool is empty
-
throw std::bad_alloc(
);
+
CDS_THROW_EXCEPTION( std::bad_alloc()
);
}
ok:
}
ok:
- assert( from_pool(p)
);
+ assert( from_pool(p));
return p;
}
return p;
}
@@
-535,7
+536,7
@@
namespace cds { namespace memory {
back_off bkoff;
// The queue can notify it is full but that is false fullness state
// So, we push in loop
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();
}
}
bkoff();
}
}