private unsafe void *Execute(C4TryLogicDelegate2 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts)
            {
                ThrowOrHandle();
            }

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

            if (retVal != null || 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);
        }
示例#2
0
        private unsafe void *Execute(C4TryLogicDelegate2 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts)
            {
                ThrowOrHandle();
            }

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

            if (retVal != null)
            {
                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);
        }
        public unsafe void *DoLockedBridge(C4TryLogicDelegate2 a)
        {
#if !NO_THREADSAFE
            lock (Lock) {
#endif
            return(LiteCoreBridge.Check(a));

#if !NO_THREADSAFE
        }
#endif
        }
        public unsafe void *Execute(C4TryLogicDelegate2 block)
        {
            var err    = default(C4Error);
            var retVal = block(&err);

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

            Exception = new LiteCoreException(err);
            ThrowOrHandle();
            return(null);
        }
示例#5
0
        public unsafe void *Execute(C4TryLogicDelegate2 block)
        {
            Debug.Assert(block != null);

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

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

            Exception = CouchbaseException.Create(err);
            ThrowOrHandle();
            return(null);
        }
 public static void* Check(C4TryLogicDelegate2 block)
 {
     return RetryHandler.RetryIfBusy().Execute(block);
 }
示例#7
0
 public static void *Check(C4TryLogicDelegate2 block)
 {
     return(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 void *Execute(C4TryLogicDelegate2 block)
 {
     return(Execute(block, 0));
 }
示例#9
0
 public static void *Check(C4TryLogicDelegate2 block)
 {
     return(NativeHandler.Create().Execute(block));
 }
示例#10
0
        private unsafe void* Execute(C4TryLogicDelegate2 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts) {
                ThrowOrHandle();
            }

            var err = default(C4Error);
            var retVal = block(&err);
            if (retVal != null) {
                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;
        }
示例#11
0
 /// <summary>
 /// Executes the specified operation
 /// </summary>
 /// <returns>The result of the operation</returns>
 /// <param name="block">The operation to run.</param>
 public unsafe void* Execute(C4TryLogicDelegate2 block)
 {
     return Execute(block, 0);
 }