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

            var err = default(C4Error);

            if (block(&err))
            {
                Exception = null;
                return(true);
            }

            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(false);
        }
        private unsafe bool Execute(C4TryLogicDelegate1 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts)
            {
                ThrowOrHandle();
            }

            var err = default(C4Error);

            if (block(&err) || err.Code == 0)
            {
                Exception = null;
                return(true);
            }

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

            ThrowOrHandle();
            return(false);
        }
        public unsafe void DoLockedBridge(C4TryLogicDelegate1 a)
        {
#if !NO_THREADSAFE
            lock (Lock) {
#endif
            LiteCoreBridge.Check(a);
#if !NO_THREADSAFE
        }
#endif
        }
        public unsafe bool Execute(C4TryLogicDelegate1 block)
        {
            var err = default(C4Error);

            if (block(&err) || err.code == 0)
            {
                Exception = null;
                return(true);
            }

            Exception = new LiteCoreException(err);
            ThrowOrHandle();
            return(false);
        }
Exemple #5
0
        public unsafe bool Execute(C4TryLogicDelegate1 block)
        {
            Debug.Assert(block != null);

            C4Error err;

            if (block(&err) || err.code == 0)
            {
                Exception = null;
                return(true);
            }

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

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

            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 false;
        }
Exemple #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 bool Execute(C4TryLogicDelegate1 block)
 {
     return Execute(block, 0);
 }
Exemple #12
0
 public static bool Check(C4TryLogicDelegate1 block)
 {
     return(NativeHandler.Create().Execute(block));
 }