コード例 #1
0
 /// <summary>
 /// Adds a child result to this result, setting this result's
 /// ResultState to Failure if the child result failed.
 /// </summary>
 /// <param name="result">The result to be added</param>
 public virtual void AddResult(ITestResult result)
 {
     _children.Enqueue(result);
     RwLock.EnterWriteLock();
     try
     {
         MergeChildResult(result);
     }
     finally
     {
         RwLock.ExitWriteLock();
     }
 }
        public VolatileLogicalTimeManager(ISnapshotHandler handler, TimeSpan snapshotInterval)
        {
            this.lastSnapshot = TimeSpan.Zero;
            this.stopwatch    = new Stopwatch();
            this.isRunning    = false;
            this.rwLock       = new RwLock();

            this.handler          = handler;
            this.snapshotInterval = snapshotInterval;
            this.timer            = new Timer(o => this.TimerCallback());

            this.stopwatch.Start();
        }
コード例 #3
0
 public bool TryTake(out T item)
 {
     using (RwLock.Read())
     {
         int count = Items.Count;
         if (count >= 1)
         {
             int idx = Random.Next(0, count);
             item = Items[idx];
             Items.RemoveAt(idx);
             return(true);
         }
     }
     item = default(T);
     return(false);
 }
コード例 #4
0
 /// <summary>
 ///     Remove one item, and return a list-copy of the rest.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="rest"></param>
 /// <returns></returns>
 public bool TryTakeOneCopyRest(out T item, out List <T> rest)
 {
     using (RwLock.Write())
     {
         int count = Items.Count;
         if (count >= 1)
         {
             item = Items[0];
             Items.RemoveAt(0);
             rest = new List <T>(Items);
             return(true);
         }
     }
     item = default(T);
     rest = default(List <T>);
     return(false);
 }
コード例 #5
0
        /// <summary>
        /// Adds a child result to this result, setting this result's
        /// ResultState to Failure if the child result failed.
        /// </summary>
        /// <param name="result">The result to be added</param>
        public virtual void AddResult(ITestResult result)
        {
#if PARALLEL
            _children.Enqueue(result);
            RwLock.EnterWriteLock();
            try
            {
                MergeChildResult(result);
            }
            finally
            {
                RwLock.ExitWriteLock();
            }
#else
            _children.Add(result);
            MergeChildResult(result);
#endif
        }
コード例 #6
0
        public T this[int index]
        {
            get
            {
                using (RwLock.Read())
                {
                    return(Items[index]);
                }
            }

            set
            {
                using (RwLock.Write())
                {
                    Items[index] = value;
                }
            }
        }
コード例 #7
0
        public bool TryAdd(T item)
        {
            bool written = false;

            try
            {
                RwLock.EnterUpgradeableReadLock();
                if (!Items.Contains(item))
                {
                    try
                    {
                        RwLock.EnterWriteLock();
                        Items.Add(item);
                        written = true;
                    }
                    finally
                    {
                        RwLock.ExitWriteLock();
                    }
                }
            }
            catch (NullReferenceException)
            {
            }
            catch (ObjectDisposedException)
            {
            }
            catch (ArgumentNullException)
            {
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            catch (ArgumentException)
            {
            }
            finally
            {
                RwLock.ExitUpgradeableReadLock();
            }

            return(written);
        }
コード例 #8
0
        /// <summary>
        /// Adds a child result to this result, setting this result's
        /// ResultState to Failure if the child result failed.
        /// </summary>
        /// <param name="result">The result to be added</param>
        public virtual void AddResult(ITestResult result)
        {
#if PARALLEL
            var childrenAsConcurrentQueue = Children as ConcurrentQueue <ITestResult>;
            if (childrenAsConcurrentQueue != null)
            {
                childrenAsConcurrentQueue.Enqueue(result);
            }
            else
#endif
            {
                var childrenAsIList = Children as IList <ITestResult>;
                if (childrenAsIList != null)
                {
                    childrenAsIList.Add(result);
                }
                else
                {
                    throw new NotSupportedException("cannot add results to Children");
                }
            }

#if PARALLEL
            RwLock.EnterWriteLock();
#endif
            try
            {
                // If this result is marked cancelled, don't change it
                if (ResultState != ResultState.Cancelled)
                {
                    switch (result.ResultState.Status)
                    {
                    case TestStatus.Passed:

                        if (ResultState.Status == TestStatus.Inconclusive)
                        {
                            SetResult(ResultState.Success);
                        }

                        break;

                    case TestStatus.Failed:


                        if (ResultState.Status != TestStatus.Failed)
                        {
                            SetResult(ResultState.ChildFailure, CHILD_ERRORS_MESSAGE);
                        }

                        break;

                    case TestStatus.Skipped:

                        if (result.ResultState.Label == "Ignored")
                        {
                            if (ResultState.Status == TestStatus.Inconclusive || ResultState.Status == TestStatus.Passed)
                            {
                                SetResult(ResultState.Ignored, CHILD_IGNORE_MESSAGE);
                            }
                        }

                        break;
                    }
                }

                InternalAssertCount += result.AssertCount;
                _passCount          += result.PassCount;
                _failCount          += result.FailCount;
                _skipCount          += result.SkipCount;
                _inconclusiveCount  += result.InconclusiveCount;
            }
            finally
            {
#if PARALLEL
                RwLock.ExitWriteLock();
#endif
            }
        }
コード例 #9
0
ファイル: TaskMessages.cs プロジェクト: Muraad/VisualRust
 public static void Init(IServiceProvider serviceProvider)
 {
     errorListProvider            = RwLock.New(new ErrorListProvider(serviceProvider));
     TaskMessages.serviceProvider = serviceProvider;
 }