﻿namespace Everbytes.Collections
{
    using System.Collections.Concurrent;
    using System.Collections.Generic;

    /// <summary>
    ///     Represents a thread-safe, unordered collection of objects that allows asynchronous consuming.
    /// </summary>
    /// <typeparam name="T">The type of the items contained in the stack.</typeparam>
    public class AsyncBag<T> : AsyncCollection<T>
    {
        /// <summary>
        ///     Initializes a new empty instance of <see cref="AsyncBag{T}" />.
        /// </summary>
        public AsyncBag() : base(new ConcurrentBag<T>())
        {
        }

        /// <summary>
        ///     Initializes a new instance of <see cref="AsyncBag{T}" /> that contains elements copied from a specified
        ///     collection.
        /// </summary>
        /// <param name="collection">The collection whose elements are copied to the new stack.</param>
        public AsyncBag(IEnumerable<T> collection) : base(new ConcurrentBag<T>(collection))
        {
        }
    }
}
