OLD | NEW |
1 /* | 1 /* |
2 ** 2008 November 05 | 2 ** 2008 November 05 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 ** Implementation of the sqlite3_pcache.xCreate method. | 542 ** Implementation of the sqlite3_pcache.xCreate method. |
543 ** | 543 ** |
544 ** Allocate a new cache. | 544 ** Allocate a new cache. |
545 */ | 545 */ |
546 static sqlite3_pcache *pcache1Create(int szPage, int bPurgeable){ | 546 static sqlite3_pcache *pcache1Create(int szPage, int bPurgeable){ |
547 PCache1 *pCache; /* The newly created page cache */ | 547 PCache1 *pCache; /* The newly created page cache */ |
548 PGroup *pGroup; /* The group the new page cache will belong to */ | 548 PGroup *pGroup; /* The group the new page cache will belong to */ |
549 int sz; /* Bytes of memory required to allocate the new cache */ | 549 int sz; /* Bytes of memory required to allocate the new cache */ |
550 | 550 |
551 /* | 551 /* |
552 ** The separateCache variable is true if each PCache has its own private | 552 ** The seperateCache variable is true if each PCache has its own private |
553 ** PGroup. In other words, separateCache is true for mode (1) where no | 553 ** PGroup. In other words, separateCache is true for mode (1) where no |
554 ** mutexing is required. | 554 ** mutexing is required. |
555 ** | 555 ** |
556 ** * Always use separate caches (mode-1) if SQLITE_SEPARATE_CACHE_POOLS | |
557 ** | |
558 ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT | 556 ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT |
559 ** | 557 ** |
560 ** * Always use a unified cache in single-threaded applications | 558 ** * Always use a unified cache in single-threaded applications |
561 ** | 559 ** |
562 ** * Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off) | 560 ** * Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off) |
563 ** use separate caches (mode-1) | 561 ** use separate caches (mode-1) |
564 */ | 562 */ |
565 #ifdef SQLITE_SEPARATE_CACHE_POOLS | 563 #if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0 |
566 const int separateCache = 1; | |
567 #elif defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0 | |
568 const int separateCache = 0; | 564 const int separateCache = 0; |
569 #else | 565 #else |
570 int separateCache = sqlite3GlobalConfig.bCoreMutex>0; | 566 int separateCache = sqlite3GlobalConfig.bCoreMutex>0; |
571 #endif | 567 #endif |
572 | 568 |
573 sz = sizeof(PCache1) + sizeof(PGroup)*separateCache; | 569 sz = sizeof(PCache1) + sizeof(PGroup)*separateCache; |
574 pCache = (PCache1 *)sqlite3_malloc(sz); | 570 pCache = (PCache1 *)sqlite3_malloc(sz); |
575 if( pCache ){ | 571 if( pCache ){ |
576 memset(pCache, 0, sz); | 572 memset(pCache, 0, sz); |
577 if( separateCache ){ | 573 if( separateCache ){ |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 int nRecyclable = 0; | 956 int nRecyclable = 0; |
961 for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){ | 957 for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){ |
962 nRecyclable++; | 958 nRecyclable++; |
963 } | 959 } |
964 *pnCurrent = pcache1.grp.nCurrentPage; | 960 *pnCurrent = pcache1.grp.nCurrentPage; |
965 *pnMax = pcache1.grp.nMaxPage; | 961 *pnMax = pcache1.grp.nMaxPage; |
966 *pnMin = pcache1.grp.nMinPage; | 962 *pnMin = pcache1.grp.nMinPage; |
967 *pnRecyclable = nRecyclable; | 963 *pnRecyclable = nRecyclable; |
968 } | 964 } |
969 #endif | 965 #endif |
OLD | NEW |