Exemple #1
0
        private unsafe int Execute(C4TryLogicDelegate3 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts)
            {
                ThrowOrHandle();
            }

            var err    = default(C4Error);
            var retVal = block(&err);

            if (retVal >= 0)
            {
                Exception = null;
                return(retVal);
            }

            Exception = new CBForestException(err);
            if (err.domain == C4ErrorDomain.ForestDB && err.code == (int)ForestDBStatus.HandleBusy)
            {
                Thread.Sleep(RETRY_TIME);
                return(Execute(block, attemptCount + 1));
            }

            ThrowOrHandle();
            return(retVal);
        }
        private unsafe int Execute(C4TryLogicDelegate3 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts)
            {
                ThrowOrHandle();
            }

            var err    = default(C4Error);
            var retVal = block(&err);

            if (retVal >= 0 || err.Code == 0)
            {
                Exception = null;
                return(retVal);
            }

            Exception = new LiteCoreException(err);
            if (err.Domain == C4ErrorDomain.ForestDB && err.Code == (int)ForestDBStatus.HandleBusy)
            {
                Task.Delay(RetryTime).Wait();
                return(Execute(block, attemptCount + 1));
            }

            ThrowOrHandle();
            return(retVal);
        }
        public unsafe int Execute(C4TryLogicDelegate3 block)
        {
            var err    = default(C4Error);
            var retVal = block(&err);

            if (retVal >= 0 || err.code == 0)
            {
                Exception = null;
                return(retVal);
            }

            Exception = new LiteCoreException(err);
            ThrowOrHandle();
            return(retVal);
        }
Exemple #4
0
        public unsafe int Execute(C4TryLogicDelegate3 block)
        {
            Debug.Assert(block != null);

            C4Error err;
            var     retVal = block(&err);

            if (retVal >= 0 || err.code == 0)
            {
                Exception = null;
                return(retVal);
            }

            Exception = CouchbaseException.Create(err);
            ThrowOrHandle();
            return(retVal);
        }
 public static void Check(C4TryLogicDelegate3 block)
 {
     RetryHandler.RetryIfBusy().Execute(block);
 }
Exemple #6
0
 public static void Check(C4TryLogicDelegate3 block)
 {
     RetryHandler.RetryIfBusy().Execute(block);
 }
 /// <summary>
 /// Executes the specified operation
 /// </summary>
 /// <returns>The result of the operation</returns>
 /// <param name="block">The operation to run.</param>
 public unsafe int Execute(C4TryLogicDelegate3 block)
 {
     return(Execute(block, 0));
 }
Exemple #8
0
 public static void Check(C4TryLogicDelegate3 block)
 {
     NativeHandler.Create().Execute(block);
 }
Exemple #9
0
        private unsafe int Execute(C4TryLogicDelegate3 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts) {
                ThrowOrHandle();
            }

            var err = default(C4Error);
            var retVal = block(&err);
            if (retVal >= 0) {
                Exception = null;
                return retVal;
            }

            Exception = new CBForestException(err);
            if (err.domain == C4ErrorDomain.ForestDB && err.code == (int)ForestDBStatus.HandleBusy) {
                Thread.Sleep(RETRY_TIME);
                return Execute(block, attemptCount + 1);
            }

            ThrowOrHandle();
            return retVal;
        }
Exemple #10
0
 /// <summary>
 /// Executes the specified operation
 /// </summary>
 /// <returns>The result of the operation</returns>
 /// <param name="block">The operation to run.</param>
 public unsafe int Execute(C4TryLogicDelegate3 block)
 {
     return Execute(block, 0);
 }