Пример #1
0
 static CallbackStatus PageInOutWrapCLS(Env env, UInt32 pgno, void* pgaddr, ref DBT pgcookie, PageInOutFcn pgInOut) {
   // construct DbEntry for pgcookie
   int size = unchecked((int)pgcookie.size);
   // we are not using a shared buffer - the call-back might take
   // a long time and we do not want to lock the buffer that long
   byte[] buffer = new byte[size];
   Marshal.Copy((IntPtr)pgcookie.data, buffer, 0, size);
   DbEntry cookieEntry = DbEntry.InOut(buffer, 0, size);
   cookieEntry.dbt.flags = pgcookie.flags;
   cookieEntry.dbt.dlen = pgcookie.dlen;
   cookieEntry.dbt.doff = pgcookie.doff;
   // call CLS compliant delegate - we assume it is not null
   return pgInOut(env, new CachePage(pgno, (IntPtr)pgaddr), ref cookieEntry);
 }
Пример #2
0
 public void CacheRegister(int fileType, PageInOutFcn pageIn, PageInOutFcn pageOut) {
   DB_ENV.PageInOutFcn pgIn = null;
   if (pageIn != null)
     pgIn = PageInWrapCLS;
   DB_ENV.PageInOutFcn pgOut = null;
   if (pageOut != null)
     pgOut = PageOutWrapCLS;
   CacheRegister(fileType, pgIn, pgOut);
   pageInCLS = pageIn;
   pageOutCLS = pageOut;
   this.pageIn = pgIn;
   this.pageOut = pgOut;
 }
Пример #3
0
 static CallbackStatus PageInOutWrapCLS(Env env, UInt32 pgno, void* pgaddr, ref DBT pgcookie, PageInOutFcn pgInOut) {
   IntPtr cookie = IntPtr.Zero;
   // extract IntPtr from DBT
   int size = unchecked((int)pgcookie.size);
   if (size != 0) {
     if (size != sizeof(IntPtr))
       throw new BdbException("Invalid page cookie.");
     cookie = *(IntPtr*)pgcookie.data;
   }
   // call CLS compliant delegate - we assume it is not null
   return pgInOut(env, new CachePage(pgno, (IntPtr)pgaddr), cookie);
 }