public override IFdbTransaction BeginTransaction(FdbTransactionMode mode, CancellationToken cancellationToken = default(CancellationToken), FdbOperationContext context = null)
		{
			return new FdbLoggedTransaction(
				base.BeginTransaction(mode, cancellationToken, context),
				true,
				this.OnCommitted
			);
		}
		public IFdbTransactionHandler CreateTransaction(FdbOperationContext context)
		{
			TransactionHandle handle = null;
			try
			{
				var err = FdbNative.DatabaseCreateTransaction(m_handle, out handle);
				if (Fdb.Failed(err))
				{
					throw Fdb.MapToException(err);
				}
				return new FdbNativeTransaction(this, handle);
			}
			catch(Exception)
			{
				if (handle != null) handle.Dispose();
				throw;
			}
		}
Exemple #3
0
		private CancellationToken m_cancellation; //PERF: readonly struct

		#endregion

		#region Constructors...

		internal FdbTransaction(FdbDatabase db, FdbOperationContext context, int id, IFdbTransactionHandler handler, FdbTransactionMode mode)
		{
			Contract.Requires(db != null && context != null && handler != null);
			Contract.Requires(context.Database != null);

			m_context = context;
			m_database = db;
			m_id = id;
			//REVIEW: the operation context may already have created its own CTS, maybe we can merge them ?
			m_cts = CancellationTokenSource.CreateLinkedTokenSource(context.Cancellation);
			m_cancellation = m_cts.Token;

			m_readOnly = (mode & FdbTransactionMode.ReadOnly) != 0;
			m_handler = handler;
		}
Exemple #4
0
 public Task <TResult> ReadAsync <TResult>(Func <IFdbReadOnlyTransaction, Task <TResult> > handler, Action <IFdbReadOnlyTransaction, TResult> success, CancellationToken ct)
 {
     ThrowIfDisposed();
     return(FdbOperationContext.RunReadWithResultAsync <TResult>(this, handler, success, ct));
 }
Exemple #5
0
 public Task <TResult> ReadAsync <TState, TResult>(TState state, Func <IFdbReadOnlyTransaction, TState, Task <TResult> > handler, CancellationToken ct)
 {
     ThrowIfDisposed();
     return(FdbOperationContext.RunReadWithResultAsync <TResult>(this, (tr) => handler(tr, state), ct));
 }
Exemple #6
0
        public virtual IFdbTransaction BeginTransaction(FdbTransactionMode mode, CancellationToken ct = default, FdbOperationContext context = null)
        {
            ThrowIfDisposed();

            // enforce read-only mode!
            if (m_readOnly)
            {
                mode |= FdbTransactionMode.ReadOnly;
            }

            if (context == null)
            {
                context = new FdbOperationContext(this, mode, ct);
            }

            return(m_database.BeginTransaction(mode, ct, context));
        }