/* * For a given rbn, it will load the 4k page into memory and return. * Also updates the queue to indicate the same. */ private void load_wrbufx(int rbn) { if (GLOBALQ.WRObj[rbn].incoretbuf != null) { cachehits++; } else { WRBuf tbuf = allocate(rbn); mfile1.Seek((long)rbn * 4096, SeekOrigin.Begin); mfile1.Read(tmpiodata, 0, 4096); CONFIG.Decrypt_Read_WRBuf(tmpiodata, tbuf.data); GLOBALQ.WRObj[rbn].incoretbuf = tbuf; refcache[cachesize++] = tbuf; } DoSnapshotWork(rbn); /* After the load, see if we have to clean up */ if (cachesize > 15 * 1024) { internal_sync_and_flush_cache_advanced(); } }
private void deallocate(WRBuf wb) { lock (iStack) { iStackTop++; iStack[iStackTop] = wb; } }
private WRBuf allocate(int r) { lock (iStack) { WRBuf wb = iStack[iStackTop]; iStackTop--; wb.reinit(r); return(wb); } }
int IComparer.Compare(object obj1, object obj2) { WRBuf w1 = (WRBuf)obj1; WRBuf w2 = (WRBuf)obj2; if (w1.get_buf_age() > w2.get_buf_age()) { return(-1); } else if (w1.get_buf_age() > w2.get_buf_age()) { return(1); } return(0); }
public WRLoader() { m_creation_time = DateTime.Now.ToUniversalTime().Ticks; for (int i = 0; i < iStack.Length; i++) { iStack[i] = new WRBuf(0); } iStackTop = iStack.Length - 1; for (int i = 0; i < GLOBALQ.WRObj.Length; i++) { GLOBALQ.WRObj[i] = new WRContainer(); } mfile1 = new FileStream(CONFIG.GetRefCntFilePath(), FileMode.OpenOrCreate, FileAccess.ReadWrite); tfile0 = new FileStream(CONFIG.GetTFilePath(), FileMode.OpenOrCreate, FileAccess.ReadWrite); dfile1 = new FileStream(CONFIG.GetDLogFilePath(), FileMode.OpenOrCreate, FileAccess.ReadWrite); }