DB_TXN_old.cs :  » Database » Berkeley-DB » BerkeleyDb » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Database » Berkeley DB 
Berkeley DB » BerkeleyDb » DB_TXN_old.cs
/*
 * This software is licensed according to the "Modified BSD License",
 * where the following substitutions are made in the license template:
 * <OWNER> = Karl Waclawek
 * <ORGANIZATION> = Karl Waclawek
 * <YEAR> = 2005
 * It can be obtained from http://opensource.org/licenses/bsd-license.html.
 */

using System;
using System.Security;
using System.Runtime.InteropServices;

namespace BerkeleyDb{
  [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize), CLSCompliant(false)]
  public unsafe struct DB_TXN
  {
    #region Private Fields (to calculate offset to API function pointers)

    DB_TXNMGR* mgrp;        /* Pointer to transaction manager. */
    DB_TXN* parent;         /* Pointer to transaction's parent. */
    DB_LSN last_lsn;        /* Lsn of last log write. */
    UInt32 txnid;           /* Unique transaction id. */
    UInt32 tid;             /* Thread id for use in MT XA. */
    IntPtr off;             /* Detail structure within region. (typedef uintptr_t roff_t;) */
    UInt32 lock_timeout;    /* Timeout for locks for this txn. (typedef u_int32_t db_timeout_t;) */
    UInt32 expire;          /* Time this txn expires. */
    void* txn_list;         /* Undo information for parent. */

    /*
    * !!!
    * Explicit representations of structures from queue.h.
    * TAILQ_ENTRY(__db_txn) links;
    * TAILQ_ENTRY(__db_txn) xalinks;
    */
    [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
    struct LINKS
    {
      DB_TXN* tqe_next;
      DB_TXN** tqe_prev;
    } 
    LINKS links;            /* Links transactions off manager. */

    [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
    struct XA_LINKS
    {
      DB_TXN* tqe_next;
      DB_TXN** tqe_prev;
    } 
    XA_LINKS xalinks;       /* Links active XA transactions. */

    /*
    * !!!
    * Explicit representations of structures from queue.h.
    * TAILQ_HEAD(__events, __txn_event) events;
    */
    [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
    struct EVENTS
    {
      TXN_EVENT* tqh_first;
      TXN_EVENT** tqh_last;
    } 
    EVENTS events;

    /*
    * !!!
    * Explicit representations of structures from queue.h.
    * STAILQ_HEAD(__logrec, __txn_logrec) logs;
    */
    [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
    struct LOGS
    {
      TXN_LOGREC* stqh_first;
      TXN_LOGREC** stqh_last;
    } 
    LOGS logs;              /* Links deferred events. */

    /*
    * !!!
    * Explicit representations of structures from queue.h.
    * TAILQ_HEAD(__kids, __db_txn) kids;
    */
    [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
    struct KIDS
    {
      DB_TXN* tqh_first;
      DB_TXN** tqh_last;
    } 
    KIDS kids;

    /*
    * !!!
    * Explicit representations of structures from queue.h.
    * TAILQ_ENTRY(__db_txn) klinks;
    */
    [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
    struct KLINKS
    {
      DB_TXN* tqe_next;
      DB_TXN** tqe_prev;
    } 
    KLINKS klinks;

    /* C++ and dotNET API private. */
    public IntPtr api_internal;   // void* api_internal;

    void* xml_internal;     /* XML API private. */

    UInt32  cursors;  /* Number of cursors open for txn */

    #endregion

    #region API Methods

    IntPtr abort;
    [UnmanagedFunctionPointer(Compile.CallConv), SuppressUnmanagedCodeSecurity]
    public delegate DbRetVal AbortFcn(DB_TXN* tid);
    public AbortFcn Abort {
      get { return (AbortFcn)Marshal.GetDelegateForFunctionPointer(abort, typeof(AbortFcn)); }
    }

    IntPtr commit;
    [UnmanagedFunctionPointer(Compile.CallConv), SuppressUnmanagedCodeSecurity]
    public delegate DbRetVal CommitFcn(DB_TXN* tid, UInt32 flags);
    public CommitFcn Commit {
      get { return (CommitFcn)Marshal.GetDelegateForFunctionPointer(commit, typeof(CommitFcn)); }
    }

    // flags must be 0
    IntPtr discard;
    [UnmanagedFunctionPointer(Compile.CallConv), SuppressUnmanagedCodeSecurity]
    public delegate DbRetVal DiscardFcn(DB_TXN* tid, UInt32 flags);
    public DiscardFcn Discard {
      get { return (DiscardFcn)Marshal.GetDelegateForFunctionPointer(discard, typeof(DiscardFcn)); }
    }

    IntPtr id;
    [UnmanagedFunctionPointer(Compile.CallConv), SuppressUnmanagedCodeSecurity]
    public delegate UInt32 IdFcn(DB_TXN* tid);
    public IdFcn Id {
      get { return (IdFcn)Marshal.GetDelegateForFunctionPointer(id, typeof(IdFcn)); }
    }

    // gid must be a byte array of fixed size Const.DB_XIDDATASIZE
    IntPtr prepare;
    [UnmanagedFunctionPointer(Compile.CallConv), SuppressUnmanagedCodeSecurity]
    public delegate DbRetVal PrepareFcn(DB_TXN* tid, byte* gid);
    public PrepareFcn Prepare {
      get { return (PrepareFcn)Marshal.GetDelegateForFunctionPointer(prepare, typeof(PrepareFcn)); }
    }

    IntPtr set_begin_lsnp;
    [UnmanagedFunctionPointer(Compile.CallConv), SuppressUnmanagedCodeSecurity]
    public delegate DbRetVal SetBeginLsnpFcn(DB_TXN* tid, out DB_LSN* lsn);
    public SetBeginLsnpFcn SetBeginLsnp {
      get { return (SetBeginLsnpFcn)Marshal.GetDelegateForFunctionPointer(set_begin_lsnp, typeof(SetBeginLsnpFcn)); }
    }

    IntPtr set_timeout;
    [UnmanagedFunctionPointer(Compile.CallConv), SuppressUnmanagedCodeSecurity]
    public delegate DbRetVal SetTimeoutFcn(DB_TXN* tid, UInt32 timeout, UInt32 flags);
    public SetTimeoutFcn SetTimeout {
      get { return (SetTimeoutFcn)Marshal.GetDelegateForFunctionPointer(set_timeout, typeof(SetTimeoutFcn)); }
    }

    #endregion

    public const UInt32 TXN_CHILDCOMMIT = 0x001;   /* Transaction that has committed. */
    public const UInt32 TXN_COMPENSATE = 0x002;    /* Compensating transaction. */
    public const UInt32 TXN_DEADLOCK = 0x004;      /* Transaction has deadlocked. */
    public const UInt32 TXN_DEGREE_2 = 0x008;      /* Has degree 2 isolation. */
    public const UInt32 TXN_DIRTY_READ = 0x010;    /* Transaction does dirty reads. */
    public const UInt32 TXN_LOCKTIMEOUT = 0x020;   /* Transaction has a lock timeout. */
    public const UInt32 TXN_MALLOC = 0x040;        /* Structure allocated by TXN system. */
    public const UInt32 TXN_NOSYNC = 0x080;        /* Do not sync on prepare and commit. */
    public const UInt32 TXN_NOWAIT = 0x100;        /* Do not wait on locks. */
    public const UInt32 TXN_RESTORED = 0x200;      /* Transaction has been restored. */
    public const UInt32 TXN_SYNC = 0x400;          /* Sync on prepare and commit. */
    UInt32 flags;
  }

  struct DB_TXNMGR
  {
    // translate if necessary (used in API call)
  }

  struct TXN_EVENT
  {
    // translate if necessary (used in API call)
  }

  struct TXN_LOGREC
  {
    // translate if necessary (used in API call)
  }

  /* Transaction statistics structures. */

  [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
  unsafe struct DB_TXN_ACTIVE
  {
    public UInt32 txnid;             /* Transaction ID */
    public UInt32 parentid;          /* Transaction ID of parent */
    public DB_LSN lsn;               /* LSN when transaction began */
    public UInt32 xa_status;         /* XA status */
    public fixed byte xid[DbConst.DB_XIDDATASIZE]; /* XA global transaction ID */
  }

  [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
  unsafe struct DB_TXN_STAT
  {
    public DB_LSN st_last_ckp;           /* lsn of the last checkpoint */
#if _USE_32BIT_TIME_T
    public int st_time_ckp;              /* time of last checkpoint */
#else
    public long st_time_ckp;             /* time of last checkpoint */
#endif
    public UInt32 st_last_txnid;         /* last transaction id given out */
    public UInt32 st_maxtxns;            /* maximum txns possible */
    public UInt32 st_naborts;            /* number of aborted transactions */
    public UInt32 st_nbegins;            /* number of begun transactions */
    public UInt32 st_ncommits;           /* number of committed transactions */
    public UInt32 st_nactive;            /* number of active transactions */
    public UInt32 st_nrestores;          /* number of restored transactions after recovery. */
    public UInt32 st_maxnactive;         /* maximum active transactions */
    public DB_TXN_ACTIVE* st_txnarray;   /* array of active transactions */
    public UInt32 st_region_wait;        /* Region lock granted after wait. */
    public UInt32 st_region_nowait;      /* Region lock granted without wait. */
    // must be integer of same size as pointer type - therefore use IntPtr
    public IntPtr st_regsize;            /* Region size. */
  }

  [StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
  unsafe struct DB_PREPLIST
  {
    public TxnUnion txn;
    public fixed byte gid[DbConst.DB_XIDDATASIZE];
  }

  // stores either DB_TXN* or IntPtr (GCHandle), as they have the same size
  [StructLayout(LayoutKind.Explicit)]
  unsafe struct TxnUnion
  {
    [FieldOffset(0)]
    public DB_TXN* txp;

    [FieldOffset(0)]
    public IntPtr txnHandle;
  }

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.