/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System; using System.Collections.Generic; using System.Threading; namespace QuantConnect.Interfaces { /// /// Interface used to handle items being processed and communicate busy state /// /// The item type being processed public interface IBusyCollection : IDisposable { /// /// Gets a wait handle that can be used to wait until this instance is done /// processing all of it's item /// WaitHandle WaitHandle { get; } /// /// Gets the number of items held within this collection /// int Count { get; } /// /// Returns true if processing, false otherwise /// bool IsBusy { get; } /// /// Adds the items to this collection /// /// The item to be added void Add(T item); /// /// Adds the items to this collection /// /// The item to be added /// A cancellation token to observer void Add(T item, CancellationToken cancellationToken); /// /// Marks the collection as not accepting any more additions /// void CompleteAdding(); /// /// Provides a consuming enumerable for items in this collection. /// /// An enumerable that removes and returns items from the collection IEnumerable GetConsumingEnumerable(); /// /// Provides a consuming enumerable for items in this collection. /// /// A cancellation token to observer /// An enumerable that removes and returns items from the collection IEnumerable GetConsumingEnumerable(CancellationToken cancellationToken); } }