当前位置: 首页>>代码示例>>C#>>正文


C# BtShared类代码示例

本文整理汇总了C#中BtShared的典型用法代码示例。如果您正苦于以下问题:C# BtShared类的具体用法?C# BtShared怎么用?C# BtShared使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BtShared类属于命名空间,在下文中一共展示了BtShared类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btreeGetPage

 static RC btreeGetPage(BtShared bt, Pid id, ref MemPage page, bool noContent)
 {
     Debug.Assert(MutexEx.Held(bt.Mutex));
     IPage dbPage = null;
     var rc = bt.Pager.Acquire(id, ref dbPage, noContent);
     if (rc != RC.OK) return rc;
     page = btreePageFromDbPage(dbPage, id, bt);
     return RC.OK;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:9,代码来源:Btree.cs

示例2: ptrmapPageno

 static Pid ptrmapPageno(BtShared bt, Pid id)
 {
     Debug.Assert(MutexEx.Held(bt.Mutex));
     if (id < 2) return 0;
     var pagesPerMapPage = (int)(bt.UsableSize / 5 + 1);
     var ptrMap = (Pid)((id - 2) / pagesPerMapPage);
     var ret = (Pid)(ptrMap * pagesPerMapPage) + 2;
     if (ret == PENDING_BYTE_PAGE(bt))
         ret++;
     return ret;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:11,代码来源:Btree.cs

示例3: ptrmapGet

        static RC ptrmapGet(BtShared bt, Pid key, ref PTRMAP type, ref Pid id)
        {
            Debug.Assert(MutexEx.Held(bt.Mutex));

            var page = (IPage)new PgHdr(); // The pointer map page
            var ptrmapIdx = (Pid)PTRMAP_PAGENO(bt, key); // Pointer map page index
            var rc = bt.Pager.Acquire(ptrmapIdx, ref page, false);
            if (rc != RC.OK)
                return rc;
            var ptrmap = Pager.GetData(page); // Pointer map page data

            var offset = (int)PTRMAP_PTROFFSET(ptrmapIdx, key); // Offset of entry in pointer map
            if (offset < 0)
            {
                Pager.Unref(page);
                return SysEx.CORRUPT_BKPT();
            }
            Debug.Assert(offset <= (int)bt.UsableSize - 5);
            Debug.Assert(type != 0);
            type = (PTRMAP)ptrmap[offset];
            id = ConvertEx.Get4(ptrmap, offset + 1);

            Pager.Unref(page);
            if ((byte)type < 1 || (byte)type > 5) return SysEx.CORRUPT_BKPT();
            return RC.OK;
        }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:26,代码来源:Btree.cs

示例4: btreeClearHasContent

 static void btreeClearHasContent(BtShared bt)
 {
     Bitvec.Destroy(ref bt.HasContent);
     bt.HasContent = null;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:5,代码来源:Btree.cs

示例5: saveAllCursors

 static RC saveAllCursors(BtShared bt, Pid root, BtCursor except)
 {
     Debug.Assert(MutexEx.Held(bt.Mutex));
     Debug.Assert(except == null || except.Bt == bt);
     for (var p = bt.Cursor; p != null; p = p.Next)
     {
         if (p != except && (root == 0 || p.RootID == root) && p.State == CURSOR.VALID)
         {
             var rc = saveCursorPosition(p);
             if (rc != RC.OK)
                 return rc;
         }
     }
     return RC.OK;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:15,代码来源:Btree.cs

示例6: invalidateAllOverflowCache

 static void invalidateAllOverflowCache(BtShared bt)
 {
     Debug.Assert(MutexEx.Held(bt.Mutex));
     for (var p = bt.Cursor; p != null; p = p.Next)
         invalidateOverflowCache(p);
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:6,代码来源:Btree.cs

示例7: btreeSetHasContent

 static RC btreeSetHasContent(BtShared bt, Pid id)
 {
     var rc = RC.OK;
     if (bt.HasContent == null)
     {
         Debug.Assert(id <= bt.Pages);
         bt.HasContent = new Bitvec(bt.Pages);
     }
     if (rc == RC.OK && id <= bt.HasContent.Length)
         rc = bt.HasContent.Set(id);
     return rc;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:12,代码来源:Btree.cs

示例8: allocateTempSpace

 static void allocateTempSpace(BtShared bt)
 {
     if (bt.TmpSpace == null)
         bt.TmpSpace = PCache.PageAlloc2((int)bt.PageSize);
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:5,代码来源:Btree.cs

示例9: freeTempSpace

 static void freeTempSpace(BtShared bt)
 {
     PCache.PageFree2(ref bt.TmpSpace);
     bt.TmpSpace = null;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:5,代码来源:Btree.cs

示例10: Open

        public static RC Open(VSystem vfs, string filename, BContext ctx, ref Btree btree, OPEN flags, VSystem.OPEN vfsFlags)
        {
            // True if opening an ephemeral, temporary database
            bool tempDB = string.IsNullOrEmpty(filename);

            // Set the variable isMemdb to true for an in-memory database, or false for a file-based database.
            bool memoryDB = (filename == ":memory:") ||
                (tempDB && ctx.TempInMemory()) ||
                (vfsFlags & VSystem.OPEN.MEMORY) != 0;

            Debug.Assert(ctx != null);
            Debug.Assert(vfs != null);
            Debug.Assert(MutexEx.Held(ctx.Mutex));
            Debug.Assert(((uint)flags & 0xff) == (uint)flags); // flags fit in 8 bits

            // Only a BTREE_SINGLE database can be BTREE_UNORDERED
            Debug.Assert((flags & OPEN.UNORDERED) == 0 || (flags & OPEN.SINGLE) != 0);

            // A BTREE_SINGLE database is always a temporary and/or ephemeral
            Debug.Assert((flags & OPEN.SINGLE) == 0 || tempDB);

            if (memoryDB)
                flags |= OPEN.MEMORY;
            if ((vfsFlags & VSystem.OPEN.MAIN_DB) != 0 && (memoryDB || tempDB))
                vfsFlags = (vfsFlags & ~VSystem.OPEN.MAIN_DB) | VSystem.OPEN.TEMP_DB;
            var p = new Btree(); // Handle to return
            if (p == null)
                return RC.NOMEM;
            p.InTrans = TRANS.NONE;
            p.Ctx = ctx;
#if !OMIT_SHARED_CACHE
            p.Lock.Btree = p;
            p.Lock.Table = 1;
#endif

            RC rc = RC.OK; // Result code from this function
            BtShared bt = null; // Shared part of btree structure
            MutexEx mutexOpen = null;
#if !OMIT_SHARED_CACHE && !OMIT_DISKIO
            // If this Btree is a candidate for shared cache, try to find an existing BtShared object that we can share with
            if (!tempDB && (!memoryDB || (vfsFlags & VSystem.OPEN.URI) != 0))
                if ((vfsFlags & VSystem.OPEN.SHAREDCACHE) != 0)
                {
                    string fullPathname;
                    p.Sharable_ = true;
                    if (memoryDB)
                        fullPathname = filename;
                    else
                        vfs.FullPathname(filename, out fullPathname);
                    MutexEx mutexShared;
#if THREADSAFE
                    mutexOpen = MutexEx.Alloc(MutexEx.MUTEX.STATIC_OPEN); // Prevents a race condition. Ticket #3537
                    MutexEx.Enter(mutexOpen);
                    mutexShared = MutexEx.Alloc(MutexEx.MUTEX.STATIC_MASTER);
                    MutexEx.Enter(mutexShared);
#endif
                    for (bt = _sharedCacheList; bt != null; bt = bt.Next)
                    {
                        Debug.Assert(bt.Refs > 0);
                        if (fullPathname == bt.Pager.get_Filename(false) && bt.Pager.get_Vfs() == vfs)
                        {
                            for (var i = ctx.DBs.length - 1; i >= 0; i--)
                            {
                                var existing = ctx.DBs[i].Bt;
                                if (existing != null && existing.Bt == bt)
                                {
                                    MutexEx.Leave(mutexShared);
                                    MutexEx.Leave(mutexOpen);
                                    fullPathname = null;
                                    p = null;
                                    return RC.CONSTRAINT;
                                }
                            }
                            p.Bt = bt;
                            bt.Refs++;
                            break;
                        }
                    }
                    MutexEx.Leave(mutexShared);
                    fullPathname = null;
                }
#if DEBUG
                else
                    // In debug mode, we mark all persistent databases as sharable even when they are not.  This exercises the locking code and
                    // gives more opportunity for asserts(sqlite3_mutex_held()) statements to find locking problems.
                    p.Sharable_ = true;
#endif
#endif

            byte reserves; // Byte of unused space on each page
            var dbHeader = new byte[100]; // Database header content
            if (bt == null)
            {
                // The following asserts make sure that structures used by the btree are the right size.  This is to guard against size changes that result
                // when compiling on a different architecture.
                Debug.Assert(sizeof(long) == 8 || sizeof(long) == 4);
                Debug.Assert(sizeof(ulong) == 8 || sizeof(ulong) == 4);
                Debug.Assert(sizeof(uint) == 4);
                Debug.Assert(sizeof(ushort) == 2);
                Debug.Assert(sizeof(Pid) == 4);
//.........这里部分代码省略.........
开发者ID:BclEx,项目名称:GpuStructs,代码行数:101,代码来源:Btree.cs

示例11: removeFromSharingList

        static bool removeFromSharingList(BtShared bt)
        {
#if !OMIT_SHARED_CACHE
            Debug.Assert(MutexEx.Held(bt.Mutex));
#if THREADSAFE
            var master = MutexEx.Alloc(MutexEx.MUTEX.STATIC_MASTER);
#endif
            var removed = false;
            MutexEx.Enter(master);
            bt.Refs--;
            if (bt.Refs <= 0)
            {
                if (_sharedCacheList == bt)
                    _sharedCacheList = bt.Next;
                else
                {
                    var list = _sharedCacheList;
                    while (C._ALWAYS(list != null) && list.Next != bt)
                        list = list.Next;
                    if (C._ALWAYS(list != null))
                        list.Next = bt.Next;
                }
#if THREADSAFE
                MutexEx.Free(bt.Mutex);
#endif
                removed = true;
            }
            MutexEx.Leave(master);
            return removed;
#else
            return true;
#endif
        }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:33,代码来源:Btree.cs

示例12: getAndInitPage

        static RC getAndInitPage(BtShared bt, Pid id, ref MemPage page)
        {
            Debug.Assert(MutexEx.Held(bt.Mutex));

            RC rc;
            if (id > btreePagecount(bt))
                rc = SysEx.CORRUPT_BKPT();
            else
            {
                rc = btreeGetPage(bt, id, ref page, false);
                if (rc == RC.OK)
                {
                    rc = btreeInitPage(page);
                    if (rc != RC.OK)
                        releasePage(page);
                }
            }

            Debug.Assert(id != 0 || rc == RC.CORRUPT);
            return rc;
        }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:21,代码来源:Btree.cs

示例13: btreePagecount

 static Pid btreePagecount(BtShared bt)
 {
     return bt.Pages;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:4,代码来源:Btree.cs

示例14: btreePageLookup

 static MemPage btreePageLookup(BtShared bt, Pid id)
 {
     Debug.Assert(MutexEx.Held(bt.Mutex));
     var dbPage = bt.Pager.Lookup(id);
     return (dbPage != null ? btreePageFromDbPage(dbPage, id, bt) : null);
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:6,代码来源:Btree.cs

示例15: countWriteCursors

 static int countWriteCursors(BtShared bt)
 {
     int r = 0;
     for (var cur = bt.Cursor; cur != null; cur = cur.Next)
         if (cur.WrFlag && cur.State != CURSOR.FAULT) r++;
     return r;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:7,代码来源:Btree.cs


注:本文中的BtShared类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。