本文整理汇总了C#中IFile.Lock方法的典型用法代码示例。如果您正苦于以下问题:C# IFile.Lock方法的具体用法?C# IFile.Lock怎么用?C# IFile.Lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFile
的用法示例。
在下文中一共展示了IFile.Lock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public virtual void Open(IFile file, int pagePoolSize)
{
lock (this)
{
if (opened)
{
throw new StorageError(StorageError.STORAGE_ALREADY_OPENED);
}
if (lockFile)
{
if (!file.Lock())
{
throw new StorageError(StorageError.STORAGE_IS_USED);
}
}
Page pg;
int i;
int indexSize = initIndexSize;
if (indexSize < dbFirstUserId)
{
indexSize = dbFirstUserId;
}
indexSize = (indexSize + dbHandlesPerPage - 1) & ~ (dbHandlesPerPage - 1);
dirtyPagesMap = new int[dbDirtyPageBitmapSize / 4 + 1];
gcThreshold = Int64.MaxValue;
backgroundGcMonitor = new object();
backgroundGcStartMonitor = new object();
gcThread = null;
gcActive = false;
gcDone = false;
allocatedDelta = 0;
nNestedTransactions = 0;
nBlockedTransactions = 0;
nCommittedTransactions = 0;
scheduledCommitTime = Int64.MaxValue;
transactionMonitor = new object();
transactionLock = new PersistentResource();
modified = false;
objectCache = CreateObjectCache(cacheKind, pagePoolSize, objectCacheInitSize);
//UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior.
classDescMap = new Hashtable();
descList = null;
header = new Header();
byte[] buf = new byte[Header.Sizeof];
int rc = file.Read(0, buf);
if (rc > 0 && rc < Header.Sizeof)
{
throw new StorageError(StorageError.DATABASE_CORRUPTED);
}
header.Unpack(buf);
if (header.curr < 0 || header.curr > 1)
{
throw new StorageError(StorageError.DATABASE_CORRUPTED);
}
if (pool == null)
{
pool = new PagePool(pagePoolSize / Page.pageSize);
pool.Open(file);
}
if (!header.initialized)
{
header.curr = currIndex = 0;
long used = Page.pageSize;
header.root[0].index = used;
header.root[0].indexSize = indexSize;
header.root[0].indexUsed = dbFirstUserId;
header.root[0].freeList = 0;
used += indexSize * 8L;
header.root[1].index = used;
header.root[1].indexSize = indexSize;
header.root[1].indexUsed = dbFirstUserId;
header.root[1].freeList = 0;
used += indexSize * 8L;
header.root[0].shadowIndex = header.root[1].index;
header.root[1].shadowIndex = header.root[0].index;
header.root[0].shadowIndexSize = indexSize;
header.root[1].shadowIndexSize = indexSize;
int bitmapPages = (int) ((used + Page.pageSize * (dbAllocationQuantum * 8 - 1) - 1) / (Page.pageSize * (dbAllocationQuantum * 8 - 1)));
long bitmapSize = (long) bitmapPages * Page.pageSize;
int usedBitmapSize = (int) (SupportClass.URShift((used + bitmapSize), (dbAllocationQuantumBits + 3)));
for (i = 0; i < bitmapPages; i++)
{
pg = pool.PutPage(used + (long) i * Page.pageSize);
byte[] bitmap = pg.data;
int n = usedBitmapSize > Page.pageSize ? Page.pageSize : usedBitmapSize;
for (int j = 0; j < n; j++)
{
bitmap[j] = (byte) 0xFF;
//.........这里部分代码省略.........