private unsafe C4Slice Execute(C4TryLogicDelegate4 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts)
            {
                ThrowOrHandle();
            }

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

            if (retVal.buf != 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 C4Slice Execute(C4TryLogicDelegate4 block, int attemptCount)
        {
            if (attemptCount > _maxAttempts)
            {
                ThrowOrHandle();
            }

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

            if (retVal.buf != 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 C4Slice Execute(C4TryLogicDelegate4 block)
        {
            var err    = default(C4Error);
            var retVal = block(&err);

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

            Exception = new LiteCoreException(err);
            ThrowOrHandle();
            return(retVal);
        }
Пример #4
0
        public unsafe FLSlice Execute(C4TryLogicDelegate4 block)
        {
            Debug.Assert(block != null);

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

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

            Exception = CouchbaseException.Create(err);
            ThrowOrHandle();
            return(retVal);
        }
 public unsafe C4Slice Execute(C4TryLogicDelegate4 block)
 {
     return(Execute(block, 0));
 }
Пример #6
0
 public static byte[] Check(C4TryLogicDelegate4 block)
 {
     return(NativeHandler.Create().Execute(block));
 }