// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Disposables
{
    /// 
    /// Represents a disposable resource that can be checked for disposal status.
    /// 
    public sealed class BooleanDisposable : ICancelable
    {
        // Keep internal! This is used as sentinel in other IDisposable implementations to detect disposal and
        // should never be exposed to user code in order to prevent users from swapping in the sentinel. Have
        // a look at the code in e.g. SingleAssignmentDisposable for usage patterns.
        internal static readonly BooleanDisposable True = new BooleanDisposable(true);
        private volatile bool _isDisposed;
        /// 
        /// Initializes a new instance of the  class.
        /// 
        public BooleanDisposable()
        {
        }
        private BooleanDisposable(bool isDisposed)
        {
            _isDisposed = isDisposed;
        }
        /// 
        /// Gets a value that indicates whether the object is disposed.
        /// 
        public bool IsDisposed
        {
            get { return _isDisposed; }
        }
        /// 
        /// Sets the status to disposed, which can be observer through the  property.
        /// 
        public void Dispose()
        {
            _isDisposed = true;
        }
    }
}