public CachePage GetLastPage(Txn txn)
        {
            uint   pgNo = 0;
            IntPtr data = GetPage(ref pgNo, txn, CachePageGetFlags.Last);

            return(new CachePage(pgNo, data));
        }
        public CachePage GetPage(int pageNo, Txn txn, bool create)
        {
            uint   pgNo = unchecked ((uint)pageNo);
            IntPtr data = GetPage(ref pgNo, txn, create ? CachePageGetFlags.Create : CachePageGetFlags.None);

            return(new CachePage(pgNo, data));
        }
Exemple #3
0
 public Int64 Get(Txn txn, Int32 delta, ReadFlags flags)
 {
     if (txn != null)
     {
         lock (txn.rscLock) {
             DB_TXN *txp = txn.CheckDisposed();
             return(Get(txp, delta, flags));
         }
     }
     else
     {
         return(Get((DB_TXN *)null, delta, flags));
     }
 }
 IntPtr GetPage(ref uint pageNo, Txn txn, CachePageGetFlags flags)
 {
     if (txn != null)
     {
         lock (txn.rscLock) {
             DB_TXN *txp = txn.CheckDisposed();
             return((IntPtr)GetPage(ref pageNo, txp, flags));
         }
     }
     else
     {
         return((IntPtr)GetPage(ref pageNo, (DB_TXN *)null, flags));
     }
 }
Exemple #5
0
        public void Open(Txn txn, ref DbEntry key, OpenFlags flags)
        {
            DbRetVal ret;

            if (txn != null)
            {
                lock (txn.rscLock) {
                    DB_TXN *txp = txn.CheckDisposed();
                    ret = Open(txp, ref key, flags);
                }
            }
            else
            {
                ret = Open((DB_TXN *)null, ref key, flags);
            }
            Util.CheckRetVal(ret);
        }
Exemple #6
0
        public void Remove(Txn txn, RemoveFlags flags)
        {
            DbRetVal ret;

            if (txn != null)
            {
                lock (txn.rscLock) {
                    DB_TXN *txp = txn.CheckDisposed();
                    ret = Remove(txp, flags);
                }
            }
            else
            {
                ret = Remove((DB_TXN *)null, flags);
            }
            GC.SuppressFinalize(this);
            Util.CheckRetVal(ret);
        }
 public CachePage GetLastPage(Txn txn) {
   uint pgNo = 0;
   IntPtr data = GetPage(ref pgNo, txn, CachePageGetFlags.Last);
   return new CachePage(pgNo, data);
 }
 public CachePage GetPage(int pageNo, Txn txn, bool create) {
   uint pgNo = unchecked((uint)pageNo);
   IntPtr data = GetPage(ref pgNo, txn, create ? CachePageGetFlags.Create : CachePageGetFlags.None); 
   return new CachePage(pgNo, data);
 }
 IntPtr GetPage(ref uint pageNo, Txn txn, CachePageGetFlags flags) {
   if (txn != null) {
     lock (txn.rscLock) {
       DB_TXN* txp = txn.CheckDisposed();
       return (IntPtr)GetPage(ref pageNo, txp, flags);
     }
   }
   else
     return (IntPtr)GetPage(ref pageNo, (DB_TXN*)null, flags);
 }
 public void LogPrintFile(Txn txn, string msg) {
   byte[] msgBytes = null;
   int count = Util.StrToUtf8(msg, ref msgBytes);
   if (txn != null) {
     lock (txn.rscLock) {
       DB_TXN* txp = txn.CheckDisposed();
       LogPrintFile(txp, msgBytes);
     }
   }
   else
     LogPrintFile(null, msgBytes);
 }
 public void TxnCheckpoint(int kBytes, int minutes, Txn.CheckpointMode mode) {
   DbRetVal ret;
   lock (rscLock) {
     DB_ENV* evp = CheckDisposed();
     unchecked {
       ret = evp->TxnCheckpoint(evp, (UInt32)kBytes, (UInt32)minutes, (UInt32)mode);
     }
   }
   Util.CheckRetVal(ret);
 }
 public void Remove(Txn txn, RemoveFlags flags) {
   DbRetVal ret;
   if (txn != null) {
     lock (txn.rscLock) {
       DB_TXN* txp = txn.CheckDisposed();
       ret = Remove(txp, flags);
     }
   }
   else
     ret = Remove((DB_TXN*)null, flags);
   GC.SuppressFinalize(this);
   Util.CheckRetVal(ret);
 }
    public void DbRename(Txn txn, string file, string database, string newname, WriteFlags flags) {
      byte[] fBytes = null;
      Util.StrToUtf8(file, ref fBytes);
      byte[] dBytes = null;
      Util.StrToUtf8(database, ref dBytes);
      byte[] nBytes = null;
      Util.StrToUtf8(newname, ref nBytes);

      DbRetVal ret;
      // lock environement first, to avoid deadlocks
      lock (rscLock) {
        if (txn != null) {
          lock (txn.rscLock) {
            DB_TXN* txp = txn.CheckDisposed();
            ret = DbRename(txp, fBytes, dBytes, nBytes, flags);
          }
        }
        else
          ret = DbRename(null, fBytes, dBytes, nBytes, flags);
      }
      Util.CheckRetVal(ret);
    }
 // requires synchronization lock on rscLock
 internal bool RemoveTransaction(Txn txn) {
   return transactions.Remove(txn);
 }
 public Txn CdsGroupBegin() {
   Txn txn = new Txn(this);
   DbRetVal ret;
   lock (rscLock) {
     RuntimeHelpers.PrepareConstrainedRegions();
     try { }
     finally {
       DB_TXN* txp;
       DB_ENV* evp = CheckDisposed();
       ret = evp->CdsGroupBegin(evp, out txp);
       if (ret == DbRetVal.SUCCESS) {
         txn.Initialize(txp);
         transactions.Insert(txn);
       }
     }
   }
   Util.CheckRetVal(ret);
   return txn;
 }
 public void Open(Txn txn, ref DbEntry key, OpenFlags flags) {
   DbRetVal ret;
   if (txn != null) {
     lock (txn.rscLock) {
       DB_TXN* txp = txn.CheckDisposed();
       ret = Open(txp, ref key, flags);
     }
   }
   else
     ret = Open((DB_TXN*)null, ref key, flags);
   Util.CheckRetVal(ret);
 }
 public Int64 Get(Txn txn, Int32 delta, ReadFlags flags) {
   if (txn != null) {
     lock (txn.rscLock) {
       DB_TXN* txp = txn.CheckDisposed();
       return Get(txp, delta, flags);
     }
   }
   else
     return Get((DB_TXN*)null, delta, flags);
 }
 // must be called under an environment and parent lock
 DbRetVal TxnBegin(DB_TXN* parxp, Txn txn, Txn.BeginFlags flags) {
   DbRetVal ret;
   RuntimeHelpers.PrepareConstrainedRegions();
   try { }
   finally {
     DB_TXN* txp;
     DB_ENV* evp = CheckDisposed();
     ret = evp->TxnBegin(evp, parxp, out txp, unchecked((UInt32)flags));
     if (ret == DbRetVal.SUCCESS) {
       txn.Initialize(txp);
       transactions.Insert(txn);
     }
   }
   return ret;
 }
Exemple #19
0
 /// <summary>
 /// ��ʼ��
 /// </summary>
 private void Init()
 {
     env = new Env(EnvCreateFlags.None);
     Env.OpenFlags envFlags =
     Env.OpenFlags.Create |
     Env.OpenFlags.InitLock |
     Env.OpenFlags.InitLog |
     Env.OpenFlags.InitMPool |
     Env.OpenFlags.InitTxn |
     Env.OpenFlags.Recover;
     env.Open(directory, envFlags, 0);
     txn = env.TxnBegin(null, Txn.BeginFlags.None);
     db = env.CreateDatabase(DbCreateFlags.None);
     btree = (DbHash)db.Open(txn, dbName, null, DbType.Hash, Db.OpenFlags.Create, 0);
 }
 public Txn TxnBegin(Txn parent, Txn.BeginFlags flags) {
   Txn txn = new Txn(this);
   DbRetVal ret;
   // lock environement first, to avoid deadlocks
   lock (rscLock) {
     if (parent != null) {
       lock (parent.rscLock) {
         DB_TXN* parxp = parent.CheckDisposed();
         ret = TxnBegin(parxp, txn, flags);
       }
     }
     else
       ret = TxnBegin(null, txn, flags);
   }
   Util.CheckRetVal(ret);
   return txn;
 }