本文整理汇总了C#中PCache类的典型用法代码示例。如果您正苦于以下问题:C# PCache类的具体用法?C# PCache怎么用?C# PCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PCache类属于命名空间,在下文中一共展示了PCache类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: pcacheCheckSynced
//# define expensive_assert(X)
#endif
/********************************** Linked List Management ********************/
#if !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT
/*
** Check that the pCache.pSynced variable is set correctly. If it
** is not, either fail an Debug.Assert or return zero. Otherwise, return
** non-zero. This is only used in debugging builds, as follows:
**
** expensive_assert( pcacheCheckSynced(pCache) );
*/
static int pcacheCheckSynced(PCache pCache){
PgHdr p ;
for(p=pCache.pDirtyTail; p!=pCache.pSynced; p=p.pDirtyPrev){
Debug.Assert( p.nRef !=0|| (p.flags&PGHDR_NEED_SYNC) !=0);
}
return (p==null || p.nRef!=0 || (p.flags&PGHDR_NEED_SYNC)==0)?1:0;
}
开发者ID:pragmat1c,项目名称:coolstorage,代码行数:20,代码来源:pcache_c.cs
示例2: Form1
//RESTORE
public Form1()
{
cacheFile = Application.StartupPath + "\\MyObj.bin";
InitializeComponent();
_cache = new PCache();
if (File.Exists(cacheFile))
{
FileStream fs = new FileStream(cacheFile, FileMode.Open, FileAccess.Read, FileShare.None);
byte[] array = new byte[fs.Length];
fs.Read(array, 0, (Int32)fs.Length);
fs.Close();
//below simple method converts saved byte data into cache object
if(array.Length>0)
_cache.RestoreCache(array, true);
}
CleanView(true);
}
开发者ID:wangchunlei,项目名称:MyGit,代码行数:21,代码来源:Form1.cs
示例3: sqlite3PcacheRefCount
/*
** Return the total number of referenced pages held by the cache.
*/
static int sqlite3PcacheRefCount( PCache pCache )
{
return pCache.nRef;
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:7,代码来源:pcache_c.cs
示例4: sqlite3PcacheDirtyList
/*
** Return a list of all dirty pages in the cache, sorted by page number.
*/
static PgHdr sqlite3PcacheDirtyList( PCache pCache )
{
PgHdr p;
for ( p = pCache.pDirty; p != null; p = p.pDirtyNext )
{
p.pDirty = p.pDirtyNext;
}
return pcacheSortDirtyList( pCache.pDirty );
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:12,代码来源:pcache_c.cs
示例5: sqlite3PcacheClear
/*
** Discard the contents of the cache.
*/
static void sqlite3PcacheClear( PCache pCache )
{
sqlite3PcacheTruncate( pCache, 0 );
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:7,代码来源:pcache_c.cs
示例6: sqlite3PcacheClose
/*
** Close a cache.
*/
static void sqlite3PcacheClose( PCache pCache )
{
if ( pCache.pCache != null )
{
sqlite3GlobalConfig.pcache.xDestroy( ref pCache.pCache );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:10,代码来源:pcache_c.cs
示例7: sqlite3PcacheTruncate
/*
** Drop every cache entry whose page number is greater than "pgno". The
** caller must ensure that there are no outstanding references to any pages
** other than page 1 with a page number greater than pgno.
**
** If there is a reference to page 1 and the pgno parameter passed to this
** function is 0, then the data area associated with page 1 is zeroed, but
** the page object is not dropped.
*/
static void sqlite3PcacheTruncate( PCache pCache, u32 pgno )
{
if ( pCache.pCache != null )
{
PgHdr p;
PgHdr pNext;
for ( p = pCache.pDirty; p != null; p = pNext )
{
pNext = p.pDirtyNext;
/* This routine never gets call with a positive pgno except right
** after sqlite3PcacheCleanAll(). So if there are dirty pages,
** it must be that pgno==0.
*/
Debug.Assert( p.pgno > 0 );
if ( ALWAYS( p.pgno > pgno ) )
{
Debug.Assert( ( p.flags & PGHDR_DIRTY ) != 0 );
sqlite3PcacheMakeClean( p );
}
}
if ( pgno == 0 && pCache.pPage1 != null )
{
// memset( pCache.pPage1.pData, 0, pCache.szPage );
pCache.pPage1.pData = sqlite3Malloc( pCache.szPage );
pgno = 1;
}
sqlite3GlobalConfig.pcache.xTruncate( pCache.pCache, pgno + 1 );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:38,代码来源:pcache_c.cs
示例8: sqlite3PcacheSetCachesize
/*
** Set the suggested cache-size value.
*/
static void sqlite3PcacheSetCachesize( PCache pCache, int mxPage )
{
pCache.nMax = mxPage;
if ( pCache.pCache != null )
{
sqlite3GlobalConfig.pcache.xCachesize( pCache.pCache, mxPage );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:11,代码来源:pcache_c.cs
示例9: 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
示例10: sqlite3PcacheSetPageSize
/*
** Change the page size for PCache object. The caller must ensure that there
** are no outstanding page references when this function is called.
*/
static void sqlite3PcacheSetPageSize( PCache pCache, int szPage )
{
Debug.Assert( pCache.nRef == 0 && pCache.pDirty == null );
if ( pCache.pCache != null )
{
sqlite3GlobalConfig.pcache.xDestroy( ref pCache.pCache );
pCache.pCache = null;
}
pCache.szPage = szPage;
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:14,代码来源:pcache_c.cs
示例11: sizeof
}// sizeof( PCache ); }
/*
** Create a new PCache object. Storage space to hold the object
** has already been allocated and is passed in as the p pointer.
** The caller discovers how much space needs to be allocated by
** calling sqlite3PcacheSize().
*/
static void sqlite3PcacheOpen(
int szPage, /* Size of every page */
int szExtra, /* Extra space associated with each page */
bool bPurgeable, /* True if pages are on backing store */
dxStress xStress,//int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */
object pStress, /* Argument to xStress */
PCache p /* Preallocated space for the PCache */
)
{
p.Clear();//memset(p, 0, sizeof(PCache));
p.szPage = szPage;
p.szExtra = szExtra;
p.bPurgeable = bPurgeable;
p.xStress = xStress;
p.pStress = pStress;
p.nMax = 100;
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:25,代码来源:pcache_c.cs
示例12: sqlite3PcacheTruncate
/*
** Drop every cache entry whose page number is greater than "pgno". The
** caller must ensure that there are no outstanding references to any pages
** other than page 1 with a page number greater than pgno.
**
** If there is a reference to page 1 and the pgno parameter passed to this
** function is 0, then the data area associated with page 1 is zeroed, but
** the page object is not dropped.
*/
static void sqlite3PcacheTruncate( PCache pCache, u32 pgno )
{
if ( pCache.pCache != null )
{
PgHdr p;
PgHdr pNext;
for ( p = pCache.pDirty ; p != null ; p = pNext )
{
pNext = p.pDirtyNext;
if ( p.pgno > pgno )
{
Debug.Assert( ( p.flags & PGHDR_DIRTY ) != 0 );
sqlite3PcacheMakeClean( p );
}
}
if ( pgno == 0 && pCache.pPage1 != null )
{
pCache.pPage1.pData = new byte[pCache.szPage];// memset( pCache.pPage1.pData, 0, pCache.szPage );
pgno = 1;
}
sqlite3GlobalConfig.pcache.xTruncate( pCache.pCache, pgno + 1 );
}
}
开发者ID:mbahar94,项目名称:fracture,代码行数:32,代码来源:pcache_c.cs
示例13: sqlite3PcachePagecount
/*
** Return the total number of pages in the cache.
*/
static int sqlite3PcachePagecount( PCache pCache )
{
int nPage = 0;
if ( pCache.pCache != null )
{
nPage = sqlite3GlobalConfig.pcache.xPagecount( pCache.pCache );
}
return nPage;
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:12,代码来源:pcache_c.cs
示例14: sqlite3PcacheGetCachesize
/*
** Get the suggested cache-size value.
*/
static int sqlite3PcacheGetCachesize( PCache pCache )
{
return pCache.nMax;
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:7,代码来源:pcache_c.cs
示例15: sqlite3PcacheCleanAll
/*
** Make every page in the cache clean.
*/
static void sqlite3PcacheCleanAll( PCache pCache )
{
PgHdr p;
while ( ( p = pCache.pDirty ) != null )
{
sqlite3PcacheMakeClean( p );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:11,代码来源:pcache_c.cs
示例16: sqlite3PcacheIterateDirty
/*
** For all dirty pages currently in the cache, invoke the specified
** callback. This is only used if the SQLITE_CHECK_PAGES macro is
** defined.
*/
static void sqlite3PcacheIterateDirty( PCache pCache, dxIter xIter )
{
PgHdr pDirty;
for ( pDirty = pCache.pDirty; pDirty != null; pDirty = pDirty.pDirtyNext )
{
xIter( pDirty );
}
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:13,代码来源:pcache_c.cs
示例17: sqlite3PcacheClearSyncFlags
/*
** Clear the PGHDR_NEED_SYNC flag from all dirty pages.
*/
static void sqlite3PcacheClearSyncFlags( PCache pCache )
{
PgHdr p;
for ( p = pCache.pDirty; p != null; p = p.pDirtyNext )
{
p.flags &= ~PGHDR_NEED_SYNC;
}
pCache.pSynced = pCache.pDirtyTail;
}
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:12,代码来源:pcache_c.cs
示例18: 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
示例19: 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
注:本文中的PCache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论