本文整理汇总了C#中PgHdr类的典型用法代码示例。如果您正苦于以下问题:C# PgHdr类的具体用法?C# PgHdr怎么用?C# PgHdr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PgHdr类属于命名空间,在下文中一共展示了PgHdr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: pcache1Free
private static void pcache1Free(ref PgHdr p)
{
if (p == null)
return;
if (p.CacheAllocated)
{
var pSlot = new PgFreeslot();
MutexEx.sqlite3_mutex_enter(pcache1.mutex);
StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_USED, -1);
pSlot._PgHdr = p;
pSlot.pNext = pcache1.pFree;
pcache1.pFree = pSlot;
pcache1.nFreeSlot++;
pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve;
Debug.Assert(pcache1.nFreeSlot <= pcache1.nSlot);
MutexEx.sqlite3_mutex_leave(pcache1.mutex);
}
else
{
Debug.Assert(SysEx.sqlite3MemdebugHasType(p, SysEx.MEMTYPE.PCACHE));
SysEx.sqlite3MemdebugSetType(p, SysEx.MEMTYPE.HEAP);
var iSize = MallocEx.sqlite3MallocSize(p.Data);
MutexEx.sqlite3_mutex_enter(pcache1.mutex);
StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_OVERFLOW, -iSize);
MutexEx.sqlite3_mutex_leave(pcache1.mutex);
MallocEx.sqlite3_free(ref p.Data);
}
}
开发者ID:JiujiangZhu,项目名称:feaserver,代码行数:28,代码来源:PCache1+Allocation.cs
示例2: pcacheMergeDirtyList
/*
** Merge two lists of pages connected by pDirty and in pgno order.
** Do not both fixing the pDirtyPrev pointers.
*/
static PgHdr pcacheMergeDirtyList( PgHdr pA, PgHdr pB )
{
PgHdr result = new PgHdr();
PgHdr pTail = result;
while ( pA != null && pB != null )
{
if ( pA.pgno < pB.pgno )
{
pTail.pDirty = pA;
pTail = pA;
pA = pA.pDirty;
}
else
{
pTail.pDirty = pB;
pTail = pB;
pB = pB.pDirty;
}
}
if ( pA != null )
{
pTail.pDirty = pA;
}
else if ( pB != null )
{
pTail.pDirty = pB;
}
else
{
pTail.pDirty = null;
}
return result.pDirty;
}
开发者ID:taxilian,项目名称:some_library,代码行数:37,代码来源:pcache_c.cs
示例3: pcacheAddToDirtyList
/*
** Add page pPage to the head of the dirty list (PCache1.pDirty is set to
** pPage).
*/
static void pcacheAddToDirtyList( PgHdr pPage )
{
PCache p = pPage.pCache;
Debug.Assert( pPage.pDirtyNext == null && pPage.pDirtyPrev == null && p.pDirty != pPage );
pPage.pDirtyNext = p.pDirty;
if ( pPage.pDirtyNext != null )
{
Debug.Assert( pPage.pDirtyNext.pDirtyPrev == null );
pPage.pDirtyNext.pDirtyPrev = pPage;
}
p.pDirty = pPage;
if ( null == p.pDirtyTail )
{
p.pDirtyTail = pPage;
}
if ( null == p.pSynced && 0 == ( pPage.flags & PGHDR_NEED_SYNC ) )
{
p.pSynced = pPage;
}
#if SQLITE_ENABLE_EXPENSIVE_ASSERT
expensive_assert( pcacheCheckSynced(p) );
#endif
}
开发者ID:taxilian,项目名称:some_library,代码行数:29,代码来源:pcache_c.cs
示例4: pcache1Alloc
private static PgHdr pcache1Alloc(int nByte)
{
PgHdr p = null;
Debug.Assert(MutexEx.sqlite3_mutex_notheld(pcache1.grp.mutex));
StatusEx.sqlite3StatusSet(StatusEx.STATUS.PAGECACHE_SIZE, nByte);
if (nByte <= pcache1.szSlot)
{
MutexEx.sqlite3_mutex_enter(pcache1.mutex);
p = pcache1.pFree._PgHdr;
if (p != null)
{
pcache1.pFree = pcache1.pFree.pNext;
pcache1.nFreeSlot--;
pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve;
Debug.Assert(pcache1.nFreeSlot >= 0);
StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_USED, 1);
}
MutexEx.sqlite3_mutex_leave(pcache1.mutex);
}
if (p == null)
{
// Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get it from sqlite3Malloc instead.
p = new PgHdr();
{
var sz = nByte;
MutexEx.sqlite3_mutex_enter(pcache1.mutex);
StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_OVERFLOW, sz);
MutexEx.sqlite3_mutex_leave(pcache1.mutex);
}
SysEx.sqlite3MemdebugSetType(p, SysEx.MEMTYPE.PCACHE);
}
return p;
}
开发者ID:JiujiangZhu,项目名称:feaserver,代码行数:33,代码来源:PCache1+Allocation.cs
示例5: Clear
public void Clear()
{
this.pData = null;
this.pExtra = null;
this.pDirty = null;
this.pgno = 0;
this.pPager = null;
#if SQLITE_CHECK_PAGES
this.pageHash=0;
#endif
this.flags = 0;
this.nRef = 0;
this.pCache = null;
this.pDirtyNext = null;
this.pDirtyPrev = null;
this.pPgHdr1 = null;
}
开发者ID:mbahar94,项目名称:fracture,代码行数:17,代码来源:pcache_h.cs
示例6: Clear
public void Clear()
{
sqlite3_free(ref this.pData);
this.pData = null;
this.pExtra = null;
this.pDirty = null;
this.pgno = 0;
this.pPager = null;
#if SQLITE_CHECK_PAGES
this.pageHash=0;
#endif
this.flags = 0;
this.nRef = 0;
this.CacheAllocated = false;
this.pCache = null;
this.pDirtyNext = null;
this.pDirtyPrev = null;
this.pPgHdr1 = null;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:19,代码来源:pcache_h.cs
示例7: sqlite3PcacheFetch
/*
** Try to obtain a page from the cache.
*/
static int sqlite3PcacheFetch(
PCache pCache, /* Obtain the page from this cache */
u32 pgno, /* Page number to obtain */
int createFlag, /* If true, create page if it does not exist already */
ref PgHdr ppPage /* Write the page here */
)
{
PgHdr pPage = null;
int eCreate;
Debug.Assert( pCache != null );
Debug.Assert( createFlag == 1 || createFlag == 0 );
Debug.Assert( pgno > 0 );
/* If the pluggable cache (sqlite3_pcache*) has not been allocated,
** allocate it now.
*/
if ( null == pCache.pCache && createFlag != 0 )
{
sqlite3_pcache p;
int nByte;
nByte = pCache.szPage + pCache.szExtra + 0;// sizeof( PgHdr );
p = sqlite3GlobalConfig.pcache.xCreate( nByte, pCache.bPurgeable );
//if ( null == p )
//{
// return SQLITE_NOMEM;
//}
sqlite3GlobalConfig.pcache.xCachesize( p, pCache.nMax );
pCache.pCache = p;
}
eCreate = createFlag * ( 1 + ( ( !pCache.bPurgeable || null == pCache.pDirty ) ? 1 : 0 ) );
if ( pCache.pCache != null )
{
pPage = sqlite3GlobalConfig.pcache.xFetch( pCache.pCache, pgno, eCreate );
}
if ( null == pPage && eCreate == 1 )
{
PgHdr pPg;
/* Find a dirty page to write-out and recycle. First try to find a
** page that does not require a journal-sync (one with PGHDR_NEED_SYNC
** cleared), but if that is not possible settle for any other
** unreferenced dirty page.
*/
#if SQLITE_ENABLE_EXPENSIVE_ASSERT
expensive_assert( pcacheCheckSynced(pCache) );
#endif
for ( pPg = pCache.pSynced;
pPg != null && ( pPg.nRef != 0 || ( pPg.flags & PGHDR_NEED_SYNC ) != 0 );
pPg = pPg.pDirtyPrev
)
;
pCache.pSynced = pPg;
if ( null == pPg )
{
for ( pPg = pCache.pDirtyTail; pPg != null && pPg.nRef != 0; pPg = pPg.pDirtyPrev )
;
}
if ( pPg != null )
{
int rc;
#if SQLITE_LOG_CACHE_SPILL
sqlite3_log(SQLITE_FULL,
"spill page %d making room for %d - cache used: %d/%d",
pPg->pgno, pgno,
sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache),
pCache->nMax);
#endif
rc = pCache.xStress( pCache.pStress, pPg );
if ( rc != SQLITE_OK && rc != SQLITE_BUSY )
{
return rc;
}
}
pPage = sqlite3GlobalConfig.pcache.xFetch( pCache.pCache, pgno, 2 );
}
if ( pPage != null )
{
if ( null == pPage.pData )
{
// memset(pPage, 0, sizeof(PgHdr));
pPage.pData = sqlite3Malloc( pCache.szPage );// pPage->pData = (void*)&pPage[1];
//pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage];
//memset(pPage->pExtra, 0, pCache->szExtra);
pPage.pCache = pCache;
pPage.pgno = pgno;
}
Debug.Assert( pPage.pCache == pCache );
Debug.Assert( pPage.pgno == pgno );
//assert(pPage->pData == (void*)&pPage[1]);
//assert(pPage->pExtra == (void*)&((char*)&pPage[1])[pCache->szPage]);
if ( 0 == pPage.nRef )
//.........这里部分代码省略.........
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:101,代码来源:pcache_c.cs
示例8: sqlite3PcacheRelease
/*
** Decrement the reference count on a page. If the page is clean and the
** reference count drops to 0, then it is made elible for recycling.
*/
static void sqlite3PcacheRelease( PgHdr p )
{
Debug.Assert( p.nRef > 0 );
p.nRef--;
if ( p.nRef == 0 )
{
PCache pCache = p.pCache;
pCache.nRef--;
if ( ( p.flags & PGHDR_DIRTY ) == 0 )
{
pcacheUnpin( p );
}
else
{
/* Move the page to the head of the dirty list. */
pcacheRemoveFromDirtyList( p );
pcacheAddToDirtyList( p );
}
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:24,代码来源:pcache_c.cs
示例9: pcacheRemoveFromDirtyList
/*
** Remove page pPage from the list of dirty pages.
*/
static void pcacheRemoveFromDirtyList( PgHdr pPage )
{
PCache p = pPage.pCache;
Debug.Assert( pPage.pDirtyNext != null || pPage == p.pDirtyTail );
Debug.Assert( pPage.pDirtyPrev != null || pPage == p.pDirty );
/* Update the PCache1.pSynced variable if necessary. */
if ( p.pSynced == pPage )
{
PgHdr pSynced = pPage.pDirtyPrev;
while ( pSynced != null && ( pSynced.flags & PGHDR_NEED_SYNC ) != 0 )
{
pSynced = pSynced.pDirtyPrev;
}
p.pSynced = pSynced;
}
if ( pPage.pDirtyNext != null )
{
pPage.pDirtyNext.pDirtyPrev = pPage.pDirtyPrev;
}
else
{
Debug.Assert( pPage == p.pDirtyTail );
p.pDirtyTail = pPage.pDirtyPrev;
}
if ( pPage.pDirtyPrev != null )
{
pPage.pDirtyPrev.pDirtyNext = pPage.pDirtyNext;
}
else
{
Debug.Assert( pPage == p.pDirty );
p.pDirty = pPage.pDirtyNext;
}
pPage.pDirtyNext = null;
pPage.pDirtyPrev = null;
#if SQLITE_ENABLE_EXPENSIVE_ASSERT
expensive_assert( pcacheCheckSynced(p) );
#endif
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:46,代码来源:pcache_c.cs
示例10: pcacheUnpin
/*
** Wrapper around the pluggable caches xUnpin method. If the cache is
** being used for an in-memory database, this function is a no-op.
*/
static void pcacheUnpin( PgHdr p )
{
PCache pCache = p.pCache;
if ( pCache.bPurgeable )
{
if ( p.pgno == 1 )
{
pCache.pPage1 = null;
}
sqlite3GlobalConfig.pcache.xUnpin( pCache.pCache, p, false );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:16,代码来源:pcache_c.cs
示例11: sqlite3PcacheMove
/*
** Change the page number of page p to newPgno.
*/
static void sqlite3PcacheMove( PgHdr p, Pgno newPgno )
{
PCache pCache = p.pCache;
Debug.Assert( p.nRef > 0 );
Debug.Assert( newPgno > 0 );
sqlite3GlobalConfig.pcache.xRekey( pCache.pCache, p, p.pgno, newPgno );
p.pgno = newPgno;
if ( ( p.flags & PGHDR_DIRTY ) != 0 && ( p.flags & PGHDR_NEED_SYNC ) != 0 )
{
pcacheRemoveFromDirtyList( p );
pcacheAddToDirtyList( p );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:16,代码来源:pcache_c.cs
示例12: PAGE_TO_PGHDR1
//#define PAGE_TO_PGHDR1(c, p) (PgHdr1*)(((char*)p) + c->szPage)
static PgHdr1 PAGE_TO_PGHDR1( PCache1 c, PgHdr p ) { return p.pPgHdr1; }
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:2,代码来源:pcache1_c.cs
示例13: ptrmapGet
/*
** Read an entry from the pointer map.
**
** This routine retrieves the pointer map entry for page 'key', writing
** the type and parent page number to pEType and pPgno respectively.
** An error code is returned if something goes wrong, otherwise SQLITE_OK.
*/
static int ptrmapGet( BtShared pBt, Pgno key, ref u8 pEType, ref Pgno pPgno )
{
PgHdr pDbPage = new PgHdr();/* The pointer map page */
int iPtrmap; /* Pointer map page index */
u8[] pPtrmap; /* Pointer map page data */
int offset; /* Offset of entry in pointer map */
int rc;
Debug.Assert( sqlite3_mutex_held( pBt.mutex ) );
iPtrmap = (int)PTRMAP_PAGENO( pBt, key );
rc = sqlite3PagerGet( pBt.pPager, (u32)iPtrmap, ref pDbPage );
if ( rc != 0 )
{
return rc;
}
pPtrmap = sqlite3PagerGetData( pDbPage );
offset = (int)PTRMAP_PTROFFSET( (u32)iPtrmap, key );
if ( offset < 0 )
{
sqlite3PagerUnref( pDbPage );
return SQLITE_CORRUPT_BKPT();
}
Debug.Assert( offset <= (int)pBt.usableSize - 5 );
// Under C# pEType will always exist. No need to test; //
//Debug.Assert( pEType != 0 );
pEType = pPtrmap[offset];
// Under C# pPgno will always exist. No need to test; //
//if ( pPgno != 0 )
pPgno = sqlite3Get4byte( pPtrmap, offset + 1 );
sqlite3PagerUnref( pDbPage );
if ( pEType < 1 || pEType > 5 )
return SQLITE_CORRUPT_BKPT();
return SQLITE_OK;
}
开发者ID:Carlosps,项目名称:ionicDataBase,代码行数:44,代码来源:btree_c.cs
示例14: sqlite3PcacheMakeDirty
/*
** Make sure the page is marked as dirty. If it isn't dirty already,
** make it so.
*/
static void sqlite3PcacheMakeDirty( PgHdr p )
{
p.flags &= ~PGHDR_DONT_WRITE;
Debug.Assert( p.nRef > 0 );
if ( 0 == ( p.flags & PGHDR_DIRTY ) )
{
p.flags |= PGHDR_DIRTY;
pcacheAddToDirtyList( p );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:14,代码来源:pcache_c.cs
示例15: pcache1Unpin
/*
** Implementation of the sqlite3_pcache.xUnpin method.
**
** Mark a page as unpinned (eligible for asynchronous recycling).
*/
static void pcache1Unpin( sqlite3_pcache p, PgHdr pPg, int reuseUnlikely )
{
PCache1 pCache = (PCache1)p;
PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg );
Debug.Assert( pPage.pCache == pCache );
pcache1EnterMutex();
/* It is an error to call this function if the page is already
** part of the global LRU list.
*/
Debug.Assert( pPage.pLruPrev == null && pPage.pLruNext == null );
Debug.Assert( pcache1.pLruHead != pPage && pcache1.pLruTail != pPage );
if ( reuseUnlikely != 0 || pcache1.nCurrentPage > pcache1.nMaxPage )
{
pcache1RemoveFromHash( pPage );
pcache1FreePage( ref pPage );
}
else
{
/* Add the page to the global LRU list. Normally, the page is added to
** the head of the list (last page to be recycled). However, if the
** reuseUnlikely flag passed to this function is true, the page is added
** to the tail of the list (first page to be recycled).
*/
if ( pcache1.pLruHead != null )
{
pcache1.pLruHead.pLruPrev = pPage;
pPage.pLruNext = pcache1.pLruHead;
pcache1.pLruHead = pPage;
}
else
{
pcache1.pLruTail = pPage;
pcache1.pLruHead = pPage;
}
pCache.nRecyclable++;
}
pcache1LeaveMutex();
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:47,代码来源:pcache1_c.cs
示例16: pcache1Rekey
/*
** Implementation of the sqlite3_pcache.xRekey method.
*/
static void pcache1Rekey(
sqlite3_pcache p,
PgHdr pPg,
u32 iOld,
u32 iNew
)
{
PCache1 pCache = p;
PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg );
PgHdr1 pp;
u32 h;
Debug.Assert( pPage.iKey == iOld );
Debug.Assert( pPage.pCache == pCache );
pcache1EnterMutex();
h = iOld % pCache.nHash;
pp = pCache.apHash[h];
while ( pp != pPage )
{
pp = pp.pNext;
}
if ( pp == pCache.apHash[h] ) pCache.apHash[h] = pp.pNext;
else pp.pNext = pPage.pNext;
h = iNew % pCache.nHash;
pPage.iKey = iNew;
pPage.pNext = pCache.apHash[h];
pCache.apHash[h] = pPage;
if ( iNew > pCache.iMaxKey )
{
pCache.iMaxKey = iNew;
}
pcache1LeaveMutex();
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:39,代码来源:pcache1_c.cs
示例17: sqlite3PageFree
static void sqlite3PageFree( ref PgHdr p )
{
pcache1EnterMutex();
pcache1Free( ref p );
pcache1LeaveMutex();
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:6,代码来源:pcache1_c.cs
示例18: pcache1Free
/*
** Free an allocated buffer obtained from pcache1Alloc().
*/
static void pcache1Free( ref PgHdr p )
{
Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
if ( p == null ) return;
if ( p.CacheAllocated ) //if ( p >= pcache1.pStart && p < pcache1.pEnd )
{
PgFreeslot pSlot = new PgFreeslot();
sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, -1 );
pSlot._PgHdr = p;// (PgFreeslot)p;
pSlot.pNext = pcache1.pFree;
pcache1.pFree = pSlot;
}
else
{
int iSize = sqlite3MallocSize(p.pData);
sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize );
sqlite3_free(ref p.pData);
p = null;
}
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:23,代码来源:pcache1_c.cs
示例19: pcache1Alloc
/*
** Malloc function used within this file to allocate space from the buffer
** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no
** such buffer exists or there is no space left in it, this function falls
** back to sqlite3Malloc().
*/
static PgHdr pcache1Alloc( int nByte )
{
PgHdr p;
Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
if ( nByte <= pcache1.szSlot && pcache1.pFree != null )
{
Debug.Assert( pcache1.isInit != 0 );
p = pcache1.pFree._PgHdr;
p.CacheAllocated = true;
pcache1.pFree = pcache1.pFree.pNext;
sqlite3StatusSet( SQLITE_STATUS_PAGECACHE_SIZE, nByte );
sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, 1 );
}
else
{
/* Allocate a new buffer using sqlite3Malloc. Before doing so, exit the
** global pcache mutex and unlock the pager-cache object pCache. This is
** so that if the attempt to allocate a new buffer causes the the
** configured soft-heap-limit to be breached, it will be possible to
** reclaim memory from this pager-cache.
*/
pcache1LeaveMutex();
p = new PgHdr();// p = sqlite3Malloc(nByte);
p.CacheAllocated = false;
pcache1EnterMutex();
// if( p !=null){
int sz = nByte;//int sz = sqlite3MallocSize(p);
sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, sz );
}
return p;
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:38,代码来源:pcache1_c.cs
示例20: sqlite3PcacheRef
/*
** Increase the reference count of a supplied page by 1.
*/
static void sqlite3PcacheRef( PgHdr p )
{
Debug.Assert( p.nRef > 0 );
p.nRef++;
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:8,代码来源:pcache_c.cs
注:本文中的PgHdr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论