Commit 6d4c8a61 authored by jonas@eel.(none)'s avatar jonas@eel.(none)

ndb dd -

  convert Dbtup::Page_request and pgman::Page_request to WOPool
parent ba875278
...@@ -12381,7 +12381,7 @@ void Dbtc::executeTriggers(Signal* signal, ApiConnectRecordPtr* transPtr) ...@@ -12381,7 +12381,7 @@ void Dbtc::executeTriggers(Signal* signal, ApiConnectRecordPtr* transPtr)
tmp2.release(); tmp2.release();
LocalDataBuffer<11> tmp3(pool, trigPtr.p->afterValues); LocalDataBuffer<11> tmp3(pool, trigPtr.p->afterValues);
tmp3.release(); tmp3.release();
regApiPtr->theFiredTriggers.release(trigPtr.i); regApiPtr->theFiredTriggers.release(trigPtr);
} }
trigPtr = nextTrigPtr; trigPtr = nextTrigPtr;
} }
......
...@@ -469,20 +469,21 @@ typedef Ptr<Fragoperrec> FragoperrecPtr; ...@@ -469,20 +469,21 @@ typedef Ptr<Fragoperrec> FragoperrecPtr;
struct Page_request struct Page_request
{ {
Page_request() {}
Local_key m_key; Local_key m_key;
Uint16 m_estimated_free_space; // in bytes/records
Uint16 m_list_index; // in Disk_alloc_info.m_page_requests
Uint32 m_frag_ptr_i; Uint32 m_frag_ptr_i;
Uint32 m_extent_info_ptr; Uint32 m_extent_info_ptr;
Uint16 m_ref_count; // Waiters for page Uint16 m_estimated_free_space; // in bytes/records
Uint16 m_list_index; // in Disk_alloc_info.m_page_requests
Uint16 m_ref_count; // Waiters for page
Uint16 m_uncommitted_used_space; Uint16 m_uncommitted_used_space;
union { Uint32 nextList;
Uint32 nextList;
Uint32 nextPool;
};
Uint32 prevList; Uint32 prevList;
Uint32 m_magic;
}; // 32 bytes }; // 32 bytes
typedef RecordPool<Page_request, WOPool> Page_request_pool;
typedef DLFifoListImpl<Page_request_pool, Page_request> Page_request_list;
typedef LocalDLFifoListImpl<Page_request_pool, Page_request> Local_page_request_list;
STATIC_CONST( EXTENT_SEARCH_MATRIX_COLS = 4 ); // Guarantee size STATIC_CONST( EXTENT_SEARCH_MATRIX_COLS = 4 ); // Guarantee size
STATIC_CONST( EXTENT_SEARCH_MATRIX_ROWS = 5 ); // Total size STATIC_CONST( EXTENT_SEARCH_MATRIX_ROWS = 5 ); // Total size
...@@ -518,7 +519,6 @@ typedef Ptr<Fragoperrec> FragoperrecPtr; ...@@ -518,7 +519,6 @@ typedef Ptr<Fragoperrec> FragoperrecPtr;
}; // 40 bytes }; // 40 bytes
typedef LocalDLList<Extent_info> Extent_list; typedef LocalDLList<Extent_info> Extent_list;
typedef LocalDLList<Page_request> Page_request_list;
struct Tablerec; struct Tablerec;
struct Disk_alloc_info struct Disk_alloc_info
...@@ -553,7 +553,7 @@ typedef Ptr<Fragoperrec> FragoperrecPtr; ...@@ -553,7 +553,7 @@ typedef Ptr<Fragoperrec> FragoperrecPtr;
* Requests (for update) that have sufficient space left after request * Requests (for update) that have sufficient space left after request
* these are currently being "mapped" * these are currently being "mapped"
*/ */
DLList<Page_request>::Head m_page_requests[MAX_FREE_LIST]; Page_request_list::Head m_page_requests[MAX_FREE_LIST];
/** /**
* Current extent * Current extent
...@@ -1010,7 +1010,7 @@ ArrayPool<TupTriggerData> c_triggerPool; ...@@ -1010,7 +1010,7 @@ ArrayPool<TupTriggerData> c_triggerPool;
}; };
ArrayPool<Extent_info> c_extent_pool; ArrayPool<Extent_info> c_extent_pool;
ArrayPool<Page_request> c_page_request_pool; Page_request_pool c_page_request_pool;
DLHashTable<Extent_info> c_extent_hash; DLHashTable<Extent_info> c_extent_hash;
typedef Ptr<Tablerec> TablerecPtr; typedef Ptr<Tablerec> TablerecPtr;
...@@ -2609,13 +2609,6 @@ private: ...@@ -2609,13 +2609,6 @@ private:
void disk_page_free(Signal*, void disk_page_free(Signal*,
Tablerec*, Fragrecord*, Local_key*, PagePtr, Uint32); Tablerec*, Fragrecord*, Local_key*, PagePtr, Uint32);
void disk_page_update_free_space(Fragrecord*, Ptr<Page_request>,
DLList<Page_request>::Head list[],
Uint32 i, Uint32 sz);
void disk_page_update_free_space(Fragrecord*, PagePtr, Uint32 i,
Int32 uncommitted_delta,
Int32 extent_delta);
void disk_page_commit_callback(Signal*, Uint32 opPtrI, Uint32 page_id); void disk_page_commit_callback(Signal*, Uint32 opPtrI, Uint32 page_id);
void disk_page_log_buffer_callback(Signal*, Uint32 opPtrI, Uint32); void disk_page_log_buffer_callback(Signal*, Uint32 opPtrI, Uint32);
......
...@@ -89,8 +89,8 @@ Dbtup::dump_disk_alloc(Dbtup::Disk_alloc_info & alloc) ...@@ -89,8 +89,8 @@ Dbtup::dump_disk_alloc(Dbtup::Disk_alloc_info & alloc)
{ {
printf(" %d : ", i); printf(" %d : ", i);
Ptr<Page_request> ptr; Ptr<Page_request> ptr;
LocalDLList<Page_request> list(c_page_request_pool, Local_page_request_list list(c_page_request_pool,
alloc.m_page_requests[i]); alloc.m_page_requests[i]);
for(list.first(ptr); !ptr.isNull(); list.next(ptr)) for(list.first(ptr); !ptr.isNull(); list.next(ptr))
{ {
ndbout << ptr << " "; ndbout << ptr << " ";
...@@ -388,8 +388,6 @@ Dbtup::disk_page_prealloc(Signal* signal, ...@@ -388,8 +388,6 @@ Dbtup::disk_page_prealloc(Signal* signal,
return -err; return -err;
} }
new (req.p) Page_request();
req.p->m_ref_count= 1; req.p->m_ref_count= 1;
req.p->m_frag_ptr_i= fragPtr.i; req.p->m_frag_ptr_i= fragPtr.i;
req.p->m_uncommitted_used_space= sz; req.p->m_uncommitted_used_space= sz;
...@@ -510,8 +508,8 @@ Dbtup::disk_page_prealloc(Signal* signal, ...@@ -510,8 +508,8 @@ Dbtup::disk_page_prealloc(Signal* signal,
// And put page request in correct free list // And put page request in correct free list
idx= alloc.calc_page_free_bits(new_size); idx= alloc.calc_page_free_bits(new_size);
{ {
LocalDLList<Page_request> list(c_page_request_pool, Local_page_request_list list(c_page_request_pool,
alloc.m_page_requests[idx]); alloc.m_page_requests[idx]);
list.add(req); list.add(req);
} }
...@@ -605,9 +603,9 @@ Dbtup::disk_page_prealloc_transit_page(Disk_alloc_info& alloc, ...@@ -605,9 +603,9 @@ Dbtup::disk_page_prealloc_transit_page(Disk_alloc_info& alloc,
if (old_idx != new_idx) if (old_idx != new_idx)
{ {
DLList<Page_request>::Head *lists = alloc.m_page_requests; Page_request_list::Head *lists = alloc.m_page_requests;
LocalDLList<Page_request> old_list(c_page_request_pool, lists[old_idx]); Local_page_request_list old_list(c_page_request_pool, lists[old_idx]);
LocalDLList<Page_request> new_list(c_page_request_pool, lists[new_idx]); Local_page_request_list new_list(c_page_request_pool, lists[new_idx]);
old_list.remove(req); old_list.remove(req);
new_list.add(req); new_list.add(req);
...@@ -761,8 +759,8 @@ Dbtup::disk_page_prealloc_callback_common(Signal* signal, ...@@ -761,8 +759,8 @@ Dbtup::disk_page_prealloc_callback_common(Signal* signal,
} }
{ {
Page_request_list list(c_page_request_pool, Local_page_request_list list(c_page_request_pool,
alloc.m_page_requests[old_idx]); alloc.m_page_requests[old_idx]);
list.release(req); list.release(req);
} }
} }
......
...@@ -309,7 +309,10 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal) ...@@ -309,7 +309,10 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal)
c_extent_pool.setSize(8192); c_extent_pool.setSize(8192);
c_extent_hash.setSize(1024); // 4k c_extent_hash.setSize(1024); // 4k
c_page_request_pool.setSize(1000);
Pool_context pc;
pc.m_block = this;
c_page_request_pool.wo_pool_init(RT_DBTUP_PAGE_REQUEST, pc);
Uint32 nScanOp; // use TUX config for now Uint32 nScanOp; // use TUX config for now
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_SCAN_OP, &nScanOp)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_SCAN_OP, &nScanOp));
......
...@@ -90,6 +90,7 @@ static BlockInfo ALL_BLOCKS[] = { ...@@ -90,6 +90,7 @@ static BlockInfo ALL_BLOCKS[] = {
static const Uint32 ALL_BLOCKS_SZ = sizeof(ALL_BLOCKS)/sizeof(BlockInfo); static const Uint32 ALL_BLOCKS_SZ = sizeof(ALL_BLOCKS)/sizeof(BlockInfo);
static BlockReference readConfigOrder[ALL_BLOCKS_SZ] = { static BlockReference readConfigOrder[ALL_BLOCKS_SZ] = {
CMVMI_REF,
DBTUP_REF, DBTUP_REF,
DBACC_REF, DBACC_REF,
DBTC_REF, DBTC_REF,
...@@ -100,7 +101,6 @@ static BlockReference readConfigOrder[ALL_BLOCKS_SZ] = { ...@@ -100,7 +101,6 @@ static BlockReference readConfigOrder[ALL_BLOCKS_SZ] = {
NDBFS_REF, NDBFS_REF,
NDBCNTR_REF, NDBCNTR_REF,
QMGR_REF, QMGR_REF,
CMVMI_REF,
TRIX_REF, TRIX_REF,
BACKUP_REF, BACKUP_REF,
DBUTIL_REF, DBUTIL_REF,
......
...@@ -125,10 +125,13 @@ Pgman::execREAD_CONFIG_REQ(Signal* signal) ...@@ -125,10 +125,13 @@ Pgman::execREAD_CONFIG_REQ(Signal* signal)
{ {
page_buffer /= GLOBAL_PAGE_SIZE; // in pages page_buffer /= GLOBAL_PAGE_SIZE; // in pages
m_page_entry_pool.setSize(100*page_buffer); m_page_entry_pool.setSize(100*page_buffer);
m_page_request_pool.setSize(10000);
m_param.m_max_pages = page_buffer; m_param.m_max_pages = page_buffer;
m_param.m_max_hot_pages = (page_buffer * 9) / 10; m_param.m_max_hot_pages = (page_buffer * 9) / 10;
} }
Pool_context pc;
pc.m_block = this;
m_page_request_pool.wo_pool_init(RT_PGMAN_PAGE_REQUEST, pc);
ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend(); ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend();
conf->senderRef = reference(); conf->senderRef = reference();
...@@ -977,8 +980,7 @@ Pgman::process_callback(Signal* signal, Ptr<Page_entry> ptr) ...@@ -977,8 +980,7 @@ Pgman::process_callback(Signal* signal, Ptr<Page_entry> ptr)
* Make sure list is in own scope if callback will access this * Make sure list is in own scope if callback will access this
* list again (destructor restores list head). * list again (destructor restores list head).
*/ */
LocalDLFifoList<Page_request> Local_page_request_list req_list(m_page_request_pool, ptr.p->m_requests);
req_list(m_page_request_pool, ptr.p->m_requests);
Ptr<Page_request> req_ptr; Ptr<Page_request> req_ptr;
req_list.first(req_ptr); req_list.first(req_ptr);
...@@ -988,8 +990,6 @@ Pgman::process_callback(Signal* signal, Ptr<Page_entry> ptr) ...@@ -988,8 +990,6 @@ Pgman::process_callback(Signal* signal, Ptr<Page_entry> ptr)
b = globalData.getBlock(req_ptr.p->m_block); b = globalData.getBlock(req_ptr.p->m_block);
callback = req_ptr.p->m_callback; callback = req_ptr.p->m_callback;
req_list.release(req_ptr);
if (req_ptr.p->m_flags & DIRTY_FLAGS) if (req_ptr.p->m_flags & DIRTY_FLAGS)
{ {
jam(); jam();
...@@ -997,6 +997,8 @@ Pgman::process_callback(Signal* signal, Ptr<Page_entry> ptr) ...@@ -997,6 +997,8 @@ Pgman::process_callback(Signal* signal, Ptr<Page_entry> ptr)
ndbassert(ptr.p->m_dirty_count); ndbassert(ptr.p->m_dirty_count);
ptr.p->m_dirty_count --; ptr.p->m_dirty_count --;
} }
req_list.releaseFirst(req_ptr);
} }
ndbrequire(state & Page_entry::BOUND); ndbrequire(state & Page_entry::BOUND);
ndbrequire(state & Page_entry::MAPPED); ndbrequire(state & Page_entry::MAPPED);
...@@ -1602,12 +1604,11 @@ Pgman::get_page(Signal* signal, Ptr<Page_entry> ptr, Page_request page_req) ...@@ -1602,12 +1604,11 @@ Pgman::get_page(Signal* signal, Ptr<Page_entry> ptr, Page_request page_req)
// queue the request // queue the request
Ptr<Pgman::Page_request> req_ptr; Ptr<Pgman::Page_request> req_ptr;
{ {
LocalDLFifoList<Page_request> Local_page_request_list req_list(m_page_request_pool, ptr.p->m_requests);
req_list(m_page_request_pool, ptr.p->m_requests);
if (! (req_flags & Page_request::ALLOC_REQ)) if (! (req_flags & Page_request::ALLOC_REQ))
req_list.seize(req_ptr); req_list.seizeLast(req_ptr);
else else
req_list.seizeFront(req_ptr); req_list.seizeFirst(req_ptr);
} }
if (req_ptr.i == RNIL) if (req_ptr.i == RNIL)
...@@ -2171,8 +2172,8 @@ operator<<(NdbOut& out, Ptr<Pgman::Page_entry> ptr) ...@@ -2171,8 +2172,8 @@ operator<<(NdbOut& out, Ptr<Pgman::Page_entry> ptr)
out << " busy_count=" << dec << pe.m_busy_count; out << " busy_count=" << dec << pe.m_busy_count;
#ifdef VM_TRACE #ifdef VM_TRACE
{ {
LocalDLFifoList<Pgman::Page_request> Local_page_request_list req_list(ptr.p->m_this->m_page_request_pool,
req_list(ptr.p->m_this->m_page_request_pool, ptr.p->m_requests); ptr.p->m_requests);
if (! req_list.isEmpty()) if (! req_list.isEmpty())
{ {
Ptr<Pgman::Page_request> req_ptr; Ptr<Pgman::Page_request> req_ptr;
......
...@@ -262,13 +262,14 @@ private: ...@@ -262,13 +262,14 @@ private:
Uint16 m_flags; Uint16 m_flags;
SimulatedBlock::Callback m_callback; SimulatedBlock::Callback m_callback;
union { Uint32 nextList;
Uint32 nextPool; Uint32 m_magic;
Uint32 nextList;
};
Uint32 prevList;
}; };
typedef RecordPool<Page_request, WOPool> Page_request_pool;
typedef SLFifoListImpl<Page_request_pool, Page_request> Page_request_list;
typedef LocalSLFifoListImpl<Page_request_pool, Page_request> Local_page_request_list;
struct Page_entry_stack_ptr { struct Page_entry_stack_ptr {
Uint32 nextList; Uint32 nextList;
Uint32 prevList; Uint32 prevList;
...@@ -338,7 +339,7 @@ private: ...@@ -338,7 +339,7 @@ private:
Uint32 nextPool; Uint32 nextPool;
}; };
DLFifoList<Page_request>::Head m_requests; Page_request_list::Head m_requests;
Uint32 nextHash; Uint32 nextHash;
Uint32 prevHash; Uint32 prevHash;
...@@ -384,7 +385,7 @@ private: ...@@ -384,7 +385,7 @@ private:
File_map::DataBufferPool m_data_buffer_pool; File_map::DataBufferPool m_data_buffer_pool;
// page entries and requests // page entries and requests
ArrayPool<Page_request> m_page_request_pool; Page_request_pool m_page_request_pool;
ArrayPool<Page_entry> m_page_entry_pool; ArrayPool<Page_entry> m_page_entry_pool;
Page_hashlist m_page_hashlist; Page_hashlist m_page_hashlist;
Page_stack m_page_stack; Page_stack m_page_stack;
......
...@@ -17,20 +17,23 @@ ...@@ -17,20 +17,23 @@
#ifndef DLFIFOLIST_HPP #ifndef DLFIFOLIST_HPP
#define DLFIFOLIST_HPP #define DLFIFOLIST_HPP
#include "ArrayPool.hpp" #include <ndb_global.h>
#include <NdbOut.hpp> #include <kernel_types.h>
#include "Pool.hpp"
/** /**
* Template class used for implementing an * Template class used for implementing an
* list of object retreived from a pool * list of object retreived from a pool
*/ */
template <class T, class U = T> template <typename P, typename T, typename U = T>
class DLFifoList { class DLFifoListImpl
{
public: public:
/** /**
* List head * List head
*/ */
struct Head { struct Head
{
Head(); Head();
Uint32 firstItem; Uint32 firstItem;
Uint32 lastItem; Uint32 lastItem;
...@@ -42,61 +45,26 @@ public: ...@@ -42,61 +45,26 @@ public:
inline bool isEmpty() const { return firstItem == RNIL;} inline bool isEmpty() const { return firstItem == RNIL;}
}; };
DLFifoList(ArrayPool<T> & thePool); DLFifoListImpl(P & thePool);
/** bool seizeFirst(Ptr<T> &);
* Allocate an object from pool - update Ptr bool seizeLast(Ptr<T> &);
* bool seize(Ptr<T> & ptr) { return seizeLast(ptr);}
* Return i
*/
bool seize(Ptr<T> &);
/**
* Allocate an object from pool - update Ptr - put in front of list
*
* Return i
*/
bool seizeFront(Ptr<T> &);
/**
* Allocate object <b>i</b> from pool - update Ptr
*
* Return i
*/
bool seizeId(Ptr<T> &, Uint32 i);
/** void release(Ptr<T> &);
* Add object to list void release(); // release all
*
* @NOTE MUST be seized from correct pool void addFirst(Ptr<T> &);
*/ void addLast(Ptr<T> &);
void add(Ptr<T> &); void add(Ptr<T> & ptr) { addLast(ptr);}
/** /**
* Insert object <em>ptr</ptr> _before_ <em>loc</em> * Insert object <em>ptr</ptr> _before_ <em>loc</em>
*/ */
void insert(Ptr<T> & ptr, Ptr<T>& loc); void insert(Ptr<T> & ptr, Ptr<T>& loc);
/**
* Remove from list
*/
void remove(Ptr<T> &); void remove(Ptr<T> &);
/**
* Return an object to pool
*/
void release(Uint32 i);
/**
* Return an object to pool
*/
void release(Ptr<T> &);
/**
* Return all objects to the pool
*/
void release();
/** /**
* Update i & p value according to <b>i</b> * Update i & p value according to <b>i</b>
*/ */
...@@ -119,7 +87,6 @@ public: ...@@ -119,7 +87,6 @@ public:
*/ */
bool first(Ptr<T> &) const ; bool first(Ptr<T> &) const ;
/** /**
* Update ptr to first element in list * Update ptr to first element in list
* *
...@@ -134,7 +101,6 @@ public: ...@@ -134,7 +101,6 @@ public:
*/ */
bool next(Ptr<T> &) const ; bool next(Ptr<T> &) const ;
/** /**
* Get next element * Get next element
* *
...@@ -148,61 +114,37 @@ public: ...@@ -148,61 +114,37 @@ public:
* NOTE ptr must be both p & i * NOTE ptr must be both p & i
*/ */
bool hasNext(const Ptr<T> &) const; bool hasNext(const Ptr<T> &) const;
/** /**
* Check if prev exists i.e. this is not first * Check if next exists i.e. this is not last
* *
* NOTE ptr must be both p & i * NOTE ptr must be both p & i
*/ */
bool hasPrev(const Ptr<T> &) const; bool hasPrev(const Ptr<T> &) const;
Uint32 noOfElements() const {
Uint32 c = 0;
Uint32 i = head.firstItem;
while(i != RNIL){
c++;
const T * t = thePool.getPtr(i);
i = t->U::nextList;
}
return c;
}
/**
* Print
* (Run operator NdbOut<< on every element)
*/
void print(NdbOut & out) {
Uint32 i = head.firstItem;
while(i != RNIL){
T * t = thePool.getPtr(i);
out << (unsigned int) t << "[" << i << "]:";
t->print(out); out << " ";
i = t->U::nextList;
}
}
inline bool isEmpty() const { return head.firstItem == RNIL;} inline bool isEmpty() const { return head.firstItem == RNIL;}
/** /**
* Copy list (head) * Copy list (head)
* Will construct to identical lists * Will construct to identical lists
*/ */
DLFifoList<T>& operator=(const DLFifoList<T>& src){ DLFifoListImpl<P,T,U>& operator=(const DLFifoListImpl<P,T,U>& src){
assert(&thePool == &src.thePool); assert(&thePool == &src.thePool);
this->head = src.head; this->head = src.head;
return * this; return * this;
} }
protected: protected:
Head head; Head head;
ArrayPool<T> & thePool; P & thePool;
}; };
template <class T, class U = T> template <typename P, typename T, typename U = T>
class LocalDLFifoList : public DLFifoList<T,U> { class LocalDLFifoListImpl : public DLFifoListImpl<P,T,U>
{
public: public:
LocalDLFifoList(ArrayPool<T> & thePool, typename DLFifoList<T,U>::Head &_src) LocalDLFifoListImpl(P & thePool, typename DLFifoListImpl<P,T,U>::Head &_src)
: DLFifoList<T,U>(thePool), src(_src) : DLFifoListImpl<P,T,U>(thePool), src(_src)
{ {
this->head = src; this->head = src;
#ifdef VM_TRACE #ifdef VM_TRACE
...@@ -211,25 +153,27 @@ public: ...@@ -211,25 +153,27 @@ public:
#endif #endif
} }
~LocalDLFifoList(){ ~LocalDLFifoListImpl(){
#ifdef VM_TRACE #ifdef VM_TRACE
assert(src.in_use == true); assert(src.in_use == true);
#endif #endif
src = this->head; src = this->head;
} }
private: private:
typename DLFifoList<T,U>::Head & src; typename DLFifoListImpl<P,T,U>::Head & src;
}; };
template <class T, class U> template <typename P, typename T, typename U>
inline inline
DLFifoList<T,U>::DLFifoList(ArrayPool<T> & _pool): DLFifoListImpl<P,T,U>::DLFifoListImpl(P & _pool):
thePool(_pool){ thePool(_pool)
{
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
DLFifoList<T,U>::Head::Head(){ DLFifoListImpl<P,T,U>::Head::Head()
{
firstItem = RNIL; firstItem = RNIL;
lastItem = RNIL; lastItem = RNIL;
#ifdef VM_TRACE #ifdef VM_TRACE
...@@ -237,94 +181,83 @@ DLFifoList<T,U>::Head::Head(){ ...@@ -237,94 +181,83 @@ DLFifoList<T,U>::Head::Head(){
#endif #endif
} }
/** template <typename P, typename T, typename U>
* Allocate an object from pool - update Ptr
*
* Return i
*/
template <class T, class U>
inline inline
bool bool
DLFifoList<T,U>::seize(Ptr<T> & p){ DLFifoListImpl<P,T,U>::seizeFirst(Ptr<T> & p)
thePool.seize(p); {
if (p.i != RNIL) { if (likely(thePool.seize(p)))
add(p); {
addFirst(p);
return true; return true;
} }
p.p = NULL; p.p = NULL;
return false; return false;
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
bool bool
DLFifoList<T,U>::seizeFront(Ptr<T> & p){ DLFifoListImpl<P,T,U>::seizeLast(Ptr<T> & p)
Uint32 ff = head.firstItem; {
thePool.seize(p); if (likely(thePool.seize(p)))
if (p.i != RNIL)
{ {
p.p->U::prevList = RNIL; addLast(p);
p.p->U::nextList = ff;
head.firstItem = p.i;
if (ff == RNIL)
{
head.lastItem = p.i;
}
else
{
T * t2 = thePool.getPtr(ff);
t2->U::prevList = p.i;
}
return true; return true;
} }
p.p = NULL; p.p = NULL;
return false; return false;
} }
/** template <typename P, typename T, typename U>
* Allocate an object from pool - update Ptr
*
* Return i
*/
template <class T, class U>
inline inline
bool void
DLFifoList<T,U>::seizeId(Ptr<T> & p, Uint32 ir){ DLFifoListImpl<P,T,U>::addFirst(Ptr<T> & p)
thePool.seizeId(p, ir); {
if(p.i != RNIL){ Uint32 ff = head.firstItem;
add(p);
return true; p.p->U::prevList = RNIL;
p.p->U::nextList = ff;
head.firstItem = p.i;
if (ff == RNIL)
{
head.lastItem = p.i;
}
else
{
T * t2 = thePool.getPtr(ff);
t2->U::prevList = p.i;
} }
p.p = NULL;
return false;
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
void void
DLFifoList<T,U>::add(Ptr<T> & p){ DLFifoListImpl<P,T,U>::addLast(Ptr<T> & p)
{
T * t = p.p; T * t = p.p;
Uint32 last = head.lastItem; Uint32 last = head.lastItem;
head.lastItem = p.i;
if(p.i == RNIL)
ErrorReporter::handleAssert("DLFifoList<T,U>::add", __FILE__, __LINE__);
t->U::nextList = RNIL; t->U::nextList = RNIL;
t->U::prevList = last; t->U::prevList = last;
if (head.firstItem == RNIL)
head.firstItem = p.i;
head.lastItem = p.i;
if(last != RNIL){ if(last != RNIL)
{
T * t2 = thePool.getPtr(last); T * t2 = thePool.getPtr(last);
t2->U::nextList = p.i; t2->U::nextList = p.i;
} }
else
{
head.firstItem = p.i;
}
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
void void
DLFifoList<T,U>::insert(Ptr<T> & ptr, Ptr<T> & loc){ DLFifoListImpl<P,T,U>::insert(Ptr<T> & ptr, Ptr<T> & loc)
{
Uint32 prev= loc.p->U::prevList; Uint32 prev= loc.p->U::prevList;
if(loc.i == head.firstItem) if(loc.i == head.firstItem)
{ {
...@@ -342,88 +275,85 @@ DLFifoList<T,U>::insert(Ptr<T> & ptr, Ptr<T> & loc){ ...@@ -342,88 +275,85 @@ DLFifoList<T,U>::insert(Ptr<T> & ptr, Ptr<T> & loc){
ptr.p->U::nextList = loc.i; ptr.p->U::nextList = loc.i;
} }
/** template <typename P, typename T, typename U>
* Return an object to pool
*/
template <class T, class U>
inline
void
DLFifoList<T,U>::release(Uint32 i){
Ptr<T> p;
p.i = i;
p.p = thePool.getPtr(i);
release(p);
}
template <class T, class U>
inline inline
void void
DLFifoList<T,U>::remove(Ptr<T> & p){ DLFifoListImpl<P,T,U>::remove(Ptr<T> & p)
{
T * t = p.p; T * t = p.p;
Uint32 ni = t->U::nextList; Uint32 ni = t->U::nextList;
Uint32 pi = t->U::prevList; Uint32 pi = t->U::prevList;
if(ni != RNIL){ if(ni != RNIL)
{
T * t = thePool.getPtr(ni); T * t = thePool.getPtr(ni);
t->U::prevList = pi; t->U::prevList = pi;
} else { }
else
{
// We are releasing last // We are releasing last
head.lastItem = pi; head.lastItem = pi;
} }
if(pi != RNIL){ if(pi != RNIL)
{
T * t = thePool.getPtr(pi); T * t = thePool.getPtr(pi);
t->U::nextList = ni; t->U::nextList = ni;
} else { }
else
{
// We are releasing first // We are releasing first
head.firstItem = ni; head.firstItem = ni;
} }
} }
/**
* Return an object to pool
*/
template <class T, class U>
inline
void
DLFifoList<T,U>::release(Ptr<T> & p){
remove(p);
thePool.release(p.i);
}
template <class T, class U> template <typename P, typename T, typename U>
inline inline
void void
DLFifoList<T,U>::release(){ DLFifoListImpl<P,T,U>::release()
{
Ptr<T> p; Ptr<T> p;
while(head.firstItem != RNIL){ while(head.firstItem != RNIL)
{
p.i = head.firstItem; p.i = head.firstItem;
p.p = thePool.getPtr(head.firstItem); p.p = thePool.getPtr(head.firstItem);
T * t = p.p; T * t = p.p;
head.firstItem = t->U::nextList; head.firstItem = t->U::nextList;
release(p); release(p);
} }
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
void void
DLFifoList<T,U>::getPtr(Ptr<T> & p, Uint32 i) const { DLFifoListImpl<P,T,U>::release(Ptr<T> & p)
{
remove(p);
thePool.release(p);
}
template <typename P, typename T, typename U>
inline
void
DLFifoListImpl<P,T,U>::getPtr(Ptr<T> & p, Uint32 i) const
{
p.i = i; p.i = i;
p.p = thePool.getPtr(i); p.p = thePool.getPtr(i);
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
void void
DLFifoList<T,U>::getPtr(Ptr<T> & p) const { DLFifoListImpl<P,T,U>::getPtr(Ptr<T> & p) const
{
thePool.getPtr(p); thePool.getPtr(p);
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
T * T *
DLFifoList<T,U>::getPtr(Uint32 i) const { DLFifoListImpl<P,T,U>::getPtr(Uint32 i) const
{
return thePool.getPtr(i); return thePool.getPtr(i);
} }
...@@ -432,12 +362,14 @@ DLFifoList<T,U>::getPtr(Uint32 i) const { ...@@ -432,12 +362,14 @@ DLFifoList<T,U>::getPtr(Uint32 i) const {
* *
* Return i * Return i
*/ */
template <class T, class U> template <typename P, typename T, typename U>
inline inline
bool bool
DLFifoList<T,U>::first(Ptr<T> & p) const { DLFifoListImpl<P,T,U>::first(Ptr<T> & p) const
{
p.i = head.firstItem; p.i = head.firstItem;
if(p.i != RNIL){ if(p.i != RNIL)
{
p.p = thePool.getPtr(p.i); p.p = thePool.getPtr(p.i);
return true; return true;
} }
...@@ -445,12 +377,14 @@ DLFifoList<T,U>::first(Ptr<T> & p) const { ...@@ -445,12 +377,14 @@ DLFifoList<T,U>::first(Ptr<T> & p) const {
return false; return false;
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
bool bool
DLFifoList<T,U>::last(Ptr<T> & p) const { DLFifoListImpl<P,T,U>::last(Ptr<T> & p) const
{
p.i = head.lastItem; p.i = head.lastItem;
if(p.i != RNIL){ if(p.i != RNIL)
{
p.p = thePool.getPtr(p.i); p.p = thePool.getPtr(p.i);
return true; return true;
} }
...@@ -458,12 +392,14 @@ DLFifoList<T,U>::last(Ptr<T> & p) const { ...@@ -458,12 +392,14 @@ DLFifoList<T,U>::last(Ptr<T> & p) const {
return false; return false;
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
bool bool
DLFifoList<T,U>::next(Ptr<T> & p) const { DLFifoListImpl<P,T,U>::next(Ptr<T> & p) const
{
p.i = p.p->U::nextList; p.i = p.p->U::nextList;
if(p.i != RNIL){ if(p.i != RNIL)
{
p.p = thePool.getPtr(p.i); p.p = thePool.getPtr(p.i);
return true; return true;
} }
...@@ -471,12 +407,14 @@ DLFifoList<T,U>::next(Ptr<T> & p) const { ...@@ -471,12 +407,14 @@ DLFifoList<T,U>::next(Ptr<T> & p) const {
return false; return false;
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
bool bool
DLFifoList<T,U>::prev(Ptr<T> & p) const { DLFifoListImpl<P,T,U>::prev(Ptr<T> & p) const
{
p.i = p.p->U::prevList; p.i = p.p->U::prevList;
if(p.i != RNIL){ if(p.i != RNIL)
{
p.p = thePool.getPtr(p.i); p.p = thePool.getPtr(p.i);
return true; return true;
} }
...@@ -484,18 +422,36 @@ DLFifoList<T,U>::prev(Ptr<T> & p) const { ...@@ -484,18 +422,36 @@ DLFifoList<T,U>::prev(Ptr<T> & p) const {
return false; return false;
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
bool bool
DLFifoList<T,U>::hasNext(const Ptr<T> & p) const { DLFifoListImpl<P,T,U>::hasNext(const Ptr<T> & p) const
{
return p.p->U::nextList != RNIL; return p.p->U::nextList != RNIL;
} }
template <class T, class U> template <typename P, typename T, typename U>
inline inline
bool bool
DLFifoList<T,U>::hasPrev(const Ptr<T> & p) const { DLFifoListImpl<P,T,U>::hasPrev(const Ptr<T> & p) const
{
return p.p->U::prevList != RNIL; return p.p->U::prevList != RNIL;
} }
// Specializations
template <typename T, typename U = T>
class DLFifoList : public DLFifoListImpl<ArrayPool<T>, T, U>
{
public:
DLFifoList(ArrayPool<T> & p) : DLFifoListImpl<ArrayPool<T>, T, U>(p) {}
};
template <typename T, typename U = T>
class LocalDLFifoList : public LocalDLFifoListImpl<ArrayPool<T>,T,U> {
public:
LocalDLFifoList(ArrayPool<T> & p, typename DLFifoList<T,U>::Head & _src)
: LocalDLFifoListImpl<ArrayPool<T>,T,U>(p, _src) {}
};
#endif #endif
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#ifndef SLFIFOLIST_HPP #ifndef SLFIFOLIST_HPP
#define SLFIFOLIST_HPP #define SLFIFOLIST_HPP
#include <ndb_global.h>
#include <kernel_types.h> #include <kernel_types.h>
#include "Pool.hpp" #include "Pool.hpp"
...@@ -154,7 +155,7 @@ inline ...@@ -154,7 +155,7 @@ inline
bool bool
SLFifoListImpl<P,T,U>::seizeFirst(Ptr<T> & p) SLFifoListImpl<P,T,U>::seizeFirst(Ptr<T> & p)
{ {
if (thePool.seize(p)) if (likely(thePool.seize(p)))
{ {
addFirst(p); addFirst(p);
return true; return true;
...@@ -168,7 +169,7 @@ inline ...@@ -168,7 +169,7 @@ inline
bool bool
SLFifoListImpl<P,T,U>::seizeLast(Ptr<T> & p) SLFifoListImpl<P,T,U>::seizeLast(Ptr<T> & p)
{ {
if (thePool.seize(p)) if (likely(thePool.seize(p)))
{ {
addLast(p); addLast(p);
return true; return true;
...@@ -276,7 +277,8 @@ bool ...@@ -276,7 +277,8 @@ bool
SLFifoListImpl<P,T,U>::first(Ptr<T> & p) const SLFifoListImpl<P,T,U>::first(Ptr<T> & p) const
{ {
p.i = head.firstItem; p.i = head.firstItem;
if(p.i != RNIL){ if(p.i != RNIL)
{
p.p = thePool.getPtr(p.i); p.p = thePool.getPtr(p.i);
return true; return true;
} }
...@@ -290,7 +292,8 @@ bool ...@@ -290,7 +292,8 @@ bool
SLFifoListImpl<P,T,U>::last(Ptr<T> & p) const SLFifoListImpl<P,T,U>::last(Ptr<T> & p) const
{ {
p.i = head.lastItem; p.i = head.lastItem;
if(p.i != RNIL){ if(p.i != RNIL)
{
p.p = thePool.getPtr(p.i); p.p = thePool.getPtr(p.i);
return true; return true;
} }
...@@ -304,7 +307,8 @@ bool ...@@ -304,7 +307,8 @@ bool
SLFifoListImpl<P,T,U>::next(Ptr<T> & p) const SLFifoListImpl<P,T,U>::next(Ptr<T> & p) const
{ {
p.i = p.p->U::nextList; p.i = p.p->U::nextList;
if(p.i != RNIL){ if(p.i != RNIL)
{
p.p = thePool.getPtr(p.i); p.p = thePool.getPtr(p.i);
return true; return true;
} }
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include <signaldata/ReadConfig.hpp> #include <signaldata/ReadConfig.hpp>
#include <signaldata/UpgradeStartup.hpp> #include <signaldata/UpgradeStartup.hpp>
#include "ndbd_malloc_impl.hpp" #include "ndbd_malloc_impl.hpp"
#include <blocks/record_types.hpp>
/** /**
* Something for filesystem access * Something for filesystem access
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment